Understanding the Apple He by Jim Sather Foreword by Steve Wozniak QUTiLrry softwtirg Computer Book Division Understanding the Apple lie by James Fielding Sather BRADY COMMUNICATIONS. A Prentice-Hall CO., INC. Publishing Compa ny ^^^I'CilSs'reet Chatsworth C A 91311 MAR YLA ND 2 0 7 1 5 Lhatswonn, ^ BOWIE, Apple Books from Quality Software $22 95 Understanding the Apple II by Jim Sather lie, this book is the The companion to Understandmg the Apple the Apple II and Apple II Plus. definithle source of information about ner $19-95 Beneath Apple DOS by Don Worth and PieterLech best seller that tells all about DOb i.A. The popular ner $19-95 Beneath Apple ProDOS by Don Worth and Fieter Uch Descr ibes of how ProD OS works . A crftfcal, non-Apple explanation mg applic ations . how to use ProDO S with custo m prog ramm are Apple Utility Software from Quality Softw Don Worth and Pieter I^chner $39.95 Baa of Tricks (includes diskette) diskbyutiliti es available. Four programs The best set of DOS-based in one. Edit disk sectors, reform at single tracks, repair catalogs. Charpentier $34.95 Universal File Con version (includes diskette) by Gary SOS and ProDOS. Move data betwee n DOS 3.3, CP/M, Apple Pascal. CP/M files without a Softcar d. Format disks for any OS. Create 48-page manual explains how each OS stores differe nt file types. re. Ask for these fine products at your local computer store or booksto Or call Quality Softwar e direct, (818) 709-172 1. Production Editor: Kathryn M. Schmidt Editorial Assistant: Tom Weinstein Original Schematics and Diagrams: James Fielding Sather Art Director and Cover Design: Vic Grenrock Cover Art: George Garcia Schematic Art and Compositor: Ron Widman Photography: Gainsforth Studios Printed By; Griffin Printing ® 19S5 Quality Software. All rights reserved. No part of this book may be reprinted, or reproduced. or utilized in any form or by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying and recording, or in any information storage and retrieval system. without permission in writing from the Publisher. No patent liability is assumed with respect to the use of the information contained herein. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. ISBN0-a351-fl0n-7 87 86 85 5 432 1 Printed in the United States of America foreword / will never forget the first conversation I had with Jim Satker. He was then in the process of writing his first book. Understanding the Apple 11. Jim and I discussed the details, anoma- lies, oversights, and paradoxes of the Apple 11 hardware as we drove the LA freeways. Designers like myself find it very rewarding to encounter others who understand and appreciate what we feel are the tricks and magic of our circuits. I was able to add to the magic by erplaininff the unusual framework in which the computer was designed. From my conversations with him, and from his writing, it is obvious thai Jim has a contagious enthusiasm about Apple computers, and this enthusiasm is sure to spread to readers of his books. In Understanding the Apple II, Jim provided the definitive treatment of Apple II hardware. He has now followed that effort with the equally definitive Understanding the Apple He. Patterned after the earlier book. Understanding the Apple lie leaves no stone unturned in the search into the inner imrkings of the A pple lie computer. All facets of the A pple are revealed, from basic microprocessor operation to the inner secrets of the Apple lie custom ICs. Disk controller operation — my favorite subject — is explained in great detail. Numerous program- ming examples illustrate the application of hardware knowledge. Anyone who is at all concerned about the workings of the Apple He will benefit from this book, as will students and programmers who have a need for reliable hardware reference material. It is an incl^^sive source for a great variety of Apple lie information. The Apple lie holds a special niche in the history of microcomputers. Documentation of this quality is worthy of the computer it describes. preface It has been close to a decade s ince an unknown kid, Those who will benefit from reading Understand- having some fun in his own creative way, built the ing the Apple lie are inquiring people who want to first Apple computer. What a difference a decade spend some time learning about this machine. Gen- makes. Our boy is well known now, and he and his erally speaking, this refers to those persons who program the Apple He in any language. It is recog- pals have built nnillions of Apples with which mil- lions ofpeople have had a tremendous amount of fun nized that different people will carry their investi- in their own creative ways. gation todifferent depths. For those who do not have The creative ways of different people lead them in the time or desire to reach the greater depths, the different directions, and not all Apple owners use overview, bus structure, and I/O chapters (Chapters their computer for the same purposes. Yet diverse as 1, 2, and 7), as well as the application notes at the end they are, people who use their Apple have a common of every chapter, are recommended as providing a need for knowledg^e and understandingof the work- good foundation for understanding the Apple lie. ings of the computer. Most of them will teach them- As a textbook for students or a learning guide to selves almost everything they learn about the Apple, hard core enthusiasts, cover to cover reading is so they also have a need for tutorial literature and recommended. meaningful reference material to guide them down While an inquiring mind is the only qualification their chosen paths. required of a reader of this book, certain sections The purpose of Underfitanding the Apple lie is to will be difficult for those readers without some provide tutorial descriptions and reference mate- background knowledge. In order of descending rial concerning the most basic of Apple He related importance, helpful background knowledge in- knowledg-e. It contains explanations of how the cludes understanding of BASIC programming lan- hardware works and how programmers make the guage, hexadecimal and binary number systems, hardware work. Emphasis is placed on assisting the 6502 assembly language, and technical illustrative reader in attaining operational knowledge of the aids such as timing diagrams, truth tables, and Apple He. Operational knowledge consists of know- schematic diagrams. It should be noted by all read- ing what the Apple He can do, knowing how to make ers that (except for the technical aids) they will it do it, and knowing what a controlling program is eventually have to acquire the listed background making the Apple He do. By way of assisting the knowledge if they are to achieve a real understand- reader in achieving his goals, the goals of this book ing of the Apple He computer. It is hoped that the are: nontechnical aids and language in Understanding 1. To provide clear descriptions of microcomputer the Apple He are sufficiently descriptive, and that a fundamentals and of the operational features of technical background, although helpful, is not neces- the Apple He. sary. In general, the later chapters contain more 2. To provide examples that show how knowledge detailed and technical information than the earlier of the operational features of the Apple He can chapters, and the earlier sections in each chapter be applied. are less technically oriented. Appendices E and F 3. To provide meaningful reference material con- contain some basic information on number systems cerning Apple He hardware and operational and circuit symbols for those readers who come to features. this book with no previous knowledge of these 4. To serve as a textbook for Apple-based high subjects. school or university courses teaching computer Even though Understanding the Apple lie is not a fundamentals. programming instruction manual, many program- 5. lb fill information gaps in Apple He literature ming examples that illustrate applications of the by describing previously undocumented opera- principles being discussed are given in the body of tional features. the text. Where possible, these examples are written in BASIC so that the clearest attainable level of In deference to readers who have experience only illustration results. In addition, a number of soft- with the Apple He, descriptions in Understanding ware application notes are included at the end of the Apple lie assume that the reader is not familiar various chapters which further demonstrate the with the functioning of the older Apple H. However, application ofprincipies. These programming notes Apple II features and functions are sometimes de- are included because understanding the Apple lie scribed inorder to clarify differences between the includes a combination of programming knowledge two computers or to explain why Apple lie features and hardware knowledge. Unless noted otherwise, exist. Some notes on differences between the Apple all software examples are creations of the author II and lie are contained in Appendix I. and are hereby placed in the public domain. The There are differences among Apples that are sold author requests that he be given credit as the pro- in various regions of the world, and it is sometimes grammer inall reproductions of these programs. difficult to make statements that are accurate for all A number of hardware application notes are also versions. Generally, descriptions in this book per- included at the ends of chapters. Some of these notes tain to the Apple He as it is sold in the USA with describe hardware projects which demonstrate rele- separate sections devoted to descriptions of export vant principles. Other notes are simple descriptions versions. Readers in other countries should be aware of hardware modifications that enhance operation that some descriptions, in particular those dealing in some way. Figure 4.7 is an original design of the with signal frequency and video generation, may author. Readers are encouraged to study, build, or give details that are not accurate in their country. integrate it into their own designs. The author Those readers should rely on the sections of Chap- requests that he be given credit as the designer in ters 3and 8 that deal directly with international any reproduction or other use of this schematic. The Apples for guidance. Additionally, it should be D MAnual Controller is being manufactured by the noted that program listings in Figures 3.11 and 3.12 Southern California Research Group, and is avail- have to be modified if they are to operate correctly in able by mail as noted in Chapter 4. 50 Hz display scanning Apples such as those found Several hardware application notes detail modi- in Europe. fications tothe Apple or Apple peripherals. Please Figures 1.1, 3.8, 3.10, 5.3, 5.13, 7.1, and 8.5 illus- read the NOTE OF CAUTION following the Table trate functions internal to the Apple He special pur- of Contents before performing any modifications to pose integrated circuits (the lOU, MMU, and timing your equipment. It is recommended that readers HAL). These drawings are my own representations unskilled in electronics workmanship who desire a of those internal functions, based on my observa- modification have the work performed at a comput- tions ofApple He signals and features. These draw- er dealership or by a skilled friend. Persons who ings do not accurately show internal circuit detail, modify their hardware should be able, or know but are intended only to accurately depict internal someone who is willing and able, to repair the modi- circuit functions. fied assembly if it should fail. Understanding the Apple He is the result of an Understanding the Apple He is the companion of intensive investigation of the Apple He computer by my previously published work. Understanding the the author. There is no other source of much of the Apple II*. These two books are identical in format information covered here, and the possibility of and outline, one describing the Apple II computer error exists on the part of the author. For those and the other describing the Apple He. Readers of errors which do exist, the author is truly sorry. both books will find that, where operational features The Apple He is not a perfect computer, Apple in the two computers are identical, the text in the Computer, Inc. is not a perfect company, and I am two books is identical. Those readers will also find not a perfect author. There are many opinions of the that some application notes which are relevant to author in the body of the text, and some of them are both the Apple II and Apple He are found in both negative toward the Apple lie or the company that books. % the extent that operational features and manufactures it. The reader must rely on his own hardware implementation in the Apple He is differ- judgment to evaluate these opinions, Although I ent than that of the Apple II, Understanding the am sometimes critical of Apple Computer, Inc., I Apple He isdifferent from Understanding the Apple acknowledge that the actions of this company have enriched my life. Although I am sometimes critical of the Apple He, I believe it is the best personal •Quality Software, 198 computer that money can buy. 3. Contents Chapter 1 -The Apple lie- An Overview Chapter 5— RAM and Memory Monagemon THE 64K DYNAMIC RAM CHIP 5-1 APPLE He OVERVIEW 1-1 1-2 The Microprocessor and Bus Structure BAM CONNECTIONS IN THE APPLE He 5-3 RAM ADDRESS MULTIPLEXI NG 5-5 Memory 1-3 The Arithmetic of Video Scanner Memory Addressmg 5-7 Peripheral Slots 1-3 TEXT/LORES Scanning 5-10 The Auxiliary Slot 1-4 5-11 l-a HIRES Scanning The MMU.IOU, and Timing- HAL Mixed Mode Scanning 5-13 Video Output 1-7 1-9 REFRE SHING RAM IN THE APPLE He 5-19 The Keyboard MMU YSoftMANAG Switches EMENT 5-20 5-20 „„„„, ^ „„ Other I/O MO MEMOR The Power Supply Ml 1-11 High Memory ring betwee Configuing ($D000-$FFFF) 5-20 SUMMARY Switch n Motherboard and Auxiliary Oard Chapter 2 -The Bus Structure of the Apple lie ($C0OO-$CFFF) Configuring the I/O Range 5-28 5-28 LOGIC 2-1 KBD' and MD IN/OUT COMPUTER BUSES AND THREE STATE 2-5 The MMU Functional Diagram 5-29 THE PIGEONHOLE COMPUTER THE MPU, RAM, AND ROM 2-fi ,,^,„„ „, MMU Signal Propagation Delay 5-32 DATA DISTRIBUTION RAM ADDRESSING AND 2-10 2-7 RAM TIMING IN THE APPLE He 5-32 THE IK AUXILIARY RAM CARD 5-38 ADDRESS DECODING APPLICATION NOTES 1/0 (INPUT/OUTPUT) 2-14 2-19 Reading Video Data from a Program 5-40 THE COMPLETED BUS STRUCTURE Chapter 3-Timing Generation and the Video Scanner Chapter 6-ROM in the Apple lie TIMING OVERVIEW 3-2 BOM HARDWARE 6-1 THE TIMING SIGNALS 3-2 ROMENl' AND R0MEN2' 6-2 APPLE FREQUENCIES 3-4 PERIPHERAL SLOT ROM 6-4 THE TIMING DIAGRAM 3-5 ROM TIMING 6-4 3-7 FIRMWARE IN THE APPLE 6-6 TIMING SIGNAL DISTRIBUTION DETAILED DESCRIPTION OF TIMING SIGNALS 3-8 The System Monitor 6-6 TELEVISION SCANNING 3-12 The Apple II Plus 6-7 THE VIDEO SCANNER 3-13 The Impact of the RAM Card 6-8 THE LONG CYCLE 3-19 The Apple He 6-8 3-19 ware U pgrade 6-8 TIMING GENERATOR HARDWARE APPLICATION NOTES The APPLIC ATIONI le F irm Apple NOTES Switching Screen Modes in Timed Loops 3-23 Modifying the System Monitor 6-10 Apple Timing Loops 3-28 Modifying a 12K Firmware Card into a 24K. UU& An Applesoft Emulator for the Timing HAL A-^y HOSS 6-12 Chapter 4— The 6502 Microprocessor 6502 SIGNALS 4-2 Chapter 7-lnpu1/Output in the Apple lie 6502 CONNECTIONS IN THE APPLE He 4-4 PERIPHERAL ADDRESS DECODING CIRCUITRY 7-1 6502 MEMORY USAGE 4-5 lOU SOFT SWITCHES 7-3 6502 TIMING IN THE APPLE He 4-5 SERIAL I/O HARDWARE 7-5 APPLE PROGRAMMING 4-9 APPLE lie KEYBOARD CIRCUITRY 7-9 DMA IN THE APPLE 4-11 PERIPHERAL SLOT CONNECTIONS 7-16 6502 INTERRUPTS IN THE APPLE He 4-14 THE APPLE I/O SYSTEM: KSW AND CSW 7-23 7-21 RESET' 4-14 NMI'andlRQ' 4-15 Apple Monitor I/O 7-21 The BREAK Instruction 4-17 Linking I/O to Other Devices 7-22 Peripheral Cards and Primary I/O Devices The Enhanced Firmware IRQ'/BREAK Handler 4-18 I/O TIMING r-23 Priority Among Interrupts 4-20 THE AUXILIARY SLOT 7-26 7-37 THE 65C02 MICROPROCESSOR 4-21 APPLICATION NOTES APPLICATION NOTES Programming the Game Paddles 7-29 G502/65C02 Instruction Details 4-23 Extend ing the Game 1/0 Socket 7-33 D MAnual Controller 4-29 Gaining access to the Alternate Keyboard Set Contents tion e of the Chapter 8-Vicleo Genera Chapter 10-Malntenance and Cor PUT SIGNAL THE APPLE He VIDEO OUT 8-3 APPLE HARDWAApp RE leRELI lieABILITY 10-1 Y DWAREPRE ATIONS RESENT8-9 8-8 E'S RELIABILITY 10-3 S?lOmYMAp'MEM"0RHAR OVIN G YOUR APPL RFPAIR OF THE APPLE He 10-4 IMPR vIe GENERATOR ROM 8-11 Inputs to the Video BREAKS 10-6 8-14 and Shifting of Dot Patterns 8- 16 WHEN YOUR APPLEostic s 10-6 Sg The Firmware Diagn VWpo Generation in Export Apples 10-8 The Peripheral Card Cheek Power Supply Problems 10-8 TFYT OUTPUT 8-24 peripheral Failures 10-9 8-27 Other Symptoms 10-10 I™eS GRAPHICS OUTPUT Glossary BASIC 8-44 Appendix A- References 'SsoS™nProcess,n .ofApp,eVidec 8-47 Appendix B-Trademorks a Appendix C-6502/65C02 Dat :hapter9-The Disk Controller Listings DISK II OVERVIEW 9-1 Appendix D-RASIC Program THE DISK n DRIVE 9-5 Primer THE DISK II CONTROLLER The Bootstrap ROM 9-9 9-9 Appendix E-A Logic Circuits 9-12 s Primer Appendix F- A Number System The Command Decoder Drive Ofl/O n and Drive Select 9-1^ Head Positioning Commands 9-13 ation Appendix G-Revisional Inform READ/WRITE 9-13 and Data Register 9-14 The™s1Se leiuencer The WRITE Sequence 9-21 Appendix H- Historical Notes The READ Sequence ^-S,"?^^ _„„.. „,jyT,q q 0 -TO READ FLAGS .^e_ TIMING SIGNALS GR*1 VBL', (3.9» TO ALL BLOCKS M lOU jr^ INTERNAL SEGA SEGB GR*2 NC Jfi. VIDEO SEGC -APPLE lie IRO' GENERATOR RA9 35 (B.5) RA10 36 Me.5) 34^ VIDfi- (5.2) VI n? 37 _33_ WNDW 38 GROUND SYNC CLR6ATE' Figure 1 .1 lOU Functions and Fin Assignment*. The Apple He— An Overview 1-7 Vktoo Output Memory scanning is used to generate video in all The primary output of the Apple He is video. Th is Apple He display modes. Data that represents the video is color compatible with the television system display is stored (mapped) in RAM so that video is used in the country in which an Apple He is sold. generated by processing data that comes from RAM There are two versions of the motherboard—one as it is scanned repeatedly. Certain areas of RAM which outputs video compatible with the NTSC tel- are designated as display memory. The designated areas are: evision system used in America and other areas, and one which outputs video compatible with the PAL TEXT/LORES Page 1 $400-$7FF (IK RAM) television system used in most of western Europe TEXT/LORES Page 2 $800-$BFF (IK RAM) and other areas. An Apple He in a given country wil 1 HIRES Page 1 $2000-$3FFF(8K RAM) contain the version of the motherboard compatible HIRES Page 2 $4000-$5FFF(8K RAM) with that country's television system. Additionally, the video and keyboard ROMs will be tailored to the As an example, assume that the computer is in requirements of that country's language or lan- TEXT mode, page 1. Then memory in the range guages. $400— $7FF will be scanned approximately 60 times Video from the Apple He can be directly in put to a a second and the data in that memory area will be color or monochrome video monitor but not to a processed for video output. Part of display memory television set. Rather than video, a television accepts is always being scanned while the computer is on. RF (Radio Frequency) modulated by video. This The Apple lie is designed so that this constant scan- means that you can use the Apple He with a televi- ning satisfies the refresh requirement of the dy- sion set, but the input to the television must be an RF namic RAM. signal modulated by Apple He video. Generation of Page 1 and page 2 are primary and secondary the RF signal and modulation is accomplished in a memory display areas that are switched via the usersupplied modulator. Another name for the user PAGE2 lOU soft switch. Page 1 is normally selected supplied modulator is a pain in the neck. in all modes (PAGE2 soft switch reset), but use of There are three basic Apple He video display page 2 may suit the programmer's purpose. modes: TEXT, LORESgraphics (LOw RESoIution An important consequence of the Apple He dis- colored blocks) and HIRES graphics (High RESo- play implementation is that the video display steals Iution colored points). Additionally, LORES and memory from the user. The programmer must pro- HIRES graphics can be displayed with four lines of gram around the display areas if he intends to use text at the bottom of the screen in the Apple lie the associated displays. MIXED mode. MIXED mode is very useful, as far SINGLE-RES displays are mapped in mother- as it goes, because there are many times when the board RAM only. One byte of the display map is graphics programmer needs to enhance a display processed for each cycle of the MPU, and 40 bytes of with text. However, four 1 ines at the bottom turn out the display map are scanned to process the dis- to be inadequate for many purposes. The HIRES played portion of a single horizontal scan of the screen has good enough resolution to draw text, and television or monitor. Based on the number of bytes several programs are available that make it rela- that make up the displayed portion of a horizontal tively easy to place upper/lower case text on the scan, the SINGLE-RES TEXT, LORES, and HIRES screen. This type of text can be drawn HIRES modes will be referred to in this book as the alongside graphics to enhance graphic displays. TEXT40, LORES40, and HIRES40 modes when All display modes can be switched to normal it is necessary to distinguish them from their horizontal resolution (40 TEXT characters, 40 DOUBLE-RES counterparts. For the reason made INGRES blocks, or 280 HIRES points) or double clear in the next paragraph, the DOUBLE-RES horizontal resolution (80 TEXT characters, 80 TEXT, LORES, and HIRES modes will be referred LORESblocks.or 560 HIRES points). The SINGLE- to as the TEXT80, LORES80, and HIRES80 RES {single horizontal resolution) modes are iden- modes. tical to the display modes of the older Apple II DOUBLE-RES displays are mapped in mother- computer. The DOUBLE-RES (double horizontal board RAM and auxiliary card RAM. For every resolution) modes offer twice the characters, blocks, MPU cycle, first one byte of the auxiliary card dis- or points per horizontal display width as do the play map, then one byte of the motherboard portion SINGLE-RES modes. of the display map are processed to generate video. 1 -8 Understanding the Apple lie A total of 80 bytes of the overall display map are nating normal and inverse) are stored for each text scanned to process the displayed portion of a smgle character. One character is stored per byte of dis- horizontal scan of the television or monitor. If these play memory. As text is scanned, the coded data are numbered 0-79, the even bytes are stored m from memory is translated to 5 x 7 dot matrix video in normal, flashing, or inverse format. There are 96 auxiliary card RAM, and the odd bytes are stored m motherboard RAM. displayable upper case, lower case, numeric, punc- A RAM card must be installed in the auxihary tuation, and special text characters, all of which can slot to utilize the DOUBLE-RES modes of the Apple be displayed in normal or inverse format and 64 of He. A 64K auxiliary RAM card enables use of all which can be flashed between normal and inverse DOUBLE-RES modes, and a IK auxiliary RAM format. The TEXT display is 40 columns by 24 lines in SINGLE-RES mode and 80 columns by 24 lines card enables use of only the TEXT80 mode (80- column text).* Additionally, a IK auxiliary RAM in DOUBLE-RES mode. card enables use of LORES80 mode if a wire !S The 80-column text capability of the Apple lie is connected between pins 50 and 55 of the IK RAM implemented in hardware and in firmware so that card's edge connector. the Apple He emulates an Apple II with an 80- Scanning-for video output is not performed by the column card installed in Slot 3. This emulation is MPU but by the lOU. Inside the lOU. there is a carried out to such an extent that the Apple lie is, in counter whose outputs are used to make up the video fact, a 40-column display computer with a pe- RAM address, a television sync signal, and other ripheral 80-column capability. The Apple lie pow- video related signals. This counter synchronizes the ers in 40-column mode, and it will remain in that television scan to its addressing of RAM and can be mode up until a program, maybe or maybe not thought of as scanning RAM while it scans the tele- guided by operator input from the keyboard, selects vision (or video monitor) picture. Consequently, it is the 80-column mode. referred to in this book as the video scanner. LORES graphics is a programmable display of The scanner accesses RAM in a way that is com- 40 columns and 48 rows (SINGLE-RES) or 80 pletely transparent to the MPU. During the first columns and 48 rows (DOUBLE-RES) of colored half of every 6502 cycle period, the video scanner blocks. Each block can be any one of 15 colors accesses motherboard and auxiliary card RAM. including black and white, Apple claims 16 colors During the second half, the 6502 accesses mother- but the two grays are identical in color and lumi- board RAM, auxiliary slot RAM, or other device. nance. There are, however, 16 different LORES The scanner access to RAM is always a read access and the data which comes from RAM during the patterns, even though they produce only 15 discern- ible colors, and these will be referred to as the 16 scanner access is saved and processed by the video LORES colors. generator to make video. The 6502 access can be LORES is mapped in the same display area as either read or write and, on some cycles, the 6502 TEXT, so memory scanning is identical in the two may not access RAM at all. modes. In LORES, rather than converting ASCII to The programming method for controlling the video, the video generator processes the bit pattern Apple lie display is to select the display mode by directly into video. The code for each LORES block setting or resetting soft switches, and to compute or requires four bits, so there is code for two blocks in look up the memory addresses of screen locations every byte of display memory. Also, there is a direct and modify those addresses to achieve the desired correspondence between the screen location of a display. The video scanner scans the display area pair of LORES blocks and one text character as determined by the display mode, and the resulting shown in Figure 1.2. memory data is processed as text or graphics as determined by the display mode. HIRES40 graphics mode is a programmable TEXT characters are represented in the RAM array of 280 columns and 192 rows of dots. Because of the way video is generated in the Apple lie, the display map as ASCII (American Standard Code for Information Interchange). In addition to ASCII, color of any dot is dependent on its horizontal posi- tion. To draw a violet horizontal line, for instance, code for normal display (white on black), inverse every other dot in one row is turned on. To draw a display (black on white), or flashing display (alter- violet figure, only half of the columns of dots can be turned on. This is also true of the other HIRES40 •The DOUBLE-RES graphics modes are not available on Revi- colors: green, orange, and blue. There is only 140 x sion A motherboards. 192 resolution when drawing these four colors. The Apple Ile— An Overview 1 -9 White (the absence of color) and black (the absence cassette or disk). Virtual ly all human al phanumeric of luminance) can also be displayed. The 280 dots in input is via the keyboard , and the M PU of the A pple any row are divided into 40 groups of seven dots. lie spends the majority of its life cycling through a Each group of seven dots may be shifted top:ether little firmware routine called KEYIN(or CETKEY horizontally one half of a dot position, changinp: the if the 80-column firmware is active). This routine colors of any colored dots in that group of seven. samples the keyboard to see if a key has been Thus, there are 560 horizontal dot positions in each pressed, while incrementing a random number row, but only 280 dots are independently program- counterand occasionally flashingthescreencursor. mable. KEVIN checks the keyboard at a rate of about a 165 HIRES80 graphics mode is a projrrammabie million times an hour, and if anyone asks ,vou what arrayofSeo columns and 192 rows of dots. Eachdot an Apple does, you can answer "mainly, it checks to in the array is independently prog-rammable. and see if a key has been pressed." the horizontal resolution is so fine that all 16 LORES Enough silliness. The keyboard has 63 keys that colors can be produced, and no shifting of 7-dot pat- represent letters of the alphabet, numbers 0—9, terns isrequired or available. Resolution is 560 x punctuation characters, symbolic characters, and 192 in monochrome plotting, and varies from 140 x special functions. These keys are arranged like 192 to 560 X 192 in 16-eolor plotting depending on those of the keyboard of an IBM Svlnirir typewrit- color. er. An auto repeat function (mechanized in the lOU) This brief statementof HIRES graphics capabili- simulates rapid keypresses when a key is held down ties isprobably just enough information to let the constantly, and i)rovisions exist for programs to reader know that the subject of HIRES is complex. determine when a key is being pressed or when a key Full understanding is possible in the light of more has been pressed. Apple lie keys "roll over", mean- detailed analysis, and HIRES is covered in greater ing that if one key is held and another is pressed, the detail in Chapter 8. For now, let the resolution of the newly pressed key will be read by the controlling Apple He HIRES display be summarized as vary- program. ing from 140x 192 to 560x 192 depending on color or Most of the keys produce ASCIh\'hich can be read monochrome plotting and selection of HIRES40 or by a program, and most of the ASCII ke.vs, includ- HiRESSOmode, ing the alphabetic keys, produce shifted ASCII if The HIRES memory display area is much larger the left or right SHIFT key is held down simultane- than the TEXT/LORES area: 8192 bytes of mother- ously with the ASCII producing key. Since the key- board RAM for a HIRES40 display, and 8192 bytes board input and text output are both ASCII, it is of motherboard RAM and 8192 bytes of auxiliary fairly easy tooutput characters to the video display card RAM for a HIRES80 display. This is the hard- as they are entered from the keyboard. This is done ware cost of high resolution. by keyboard input and video output routines in the The Keyboard Apple He firmware. Special function keys on the keyboard are ESC, The keyboard is the primary human input to the DELETE, RESET. TAB. CONTROL, RETURN, Apple He (as opposed to storage med ia input such as SHIFT, CAPS LOCK, open Apple, close Apple, left 1-10 Understanding the Apple lie arrow, right arrow, down arrow, and up arrow. speak of input to the motherboard and output from CONTROLand SHIFTmodify the ASCII produced the motherboard. The peripheral slots give the Apple He an extremely versatile I/O capability, but by other simultaneously pressed keys while CAPS LOCK is a 2-position locking switch that forces there is a good deal of additional I/O circuitry built upper case ASCII from the alphabetic keys when it into the Apple lie. The keyboard input and video is latched in the down position. RESET is tied to output are the most significant motherboard I/O, There are also some useful serial I/O ports. Apple He RESET' line, and if CONTROL and Serial data is data on one line. This is opposed to RESET are pressed simultaneously, RESET' drops parallel data on more than one line (eight lines, for low to reset the Apple lie. Resetting the Apple He consists of resetting the 6502, ail MMU soft switches, instance). To transfer eight bits serially, each bitof most lOU soft switches, and all peripheral cards information is placed on the same line one after another. This takes eight times as long as an 8-bit that respond to RESET'. ESC, DELETE, TAB, RETURN, left arrow, parallel transfer, but requires only one connecting right arrow, down arrow, and up arrow produce wire. The keyboard is a parallel input. The video is ASCII which must be interpreted by the control- not a simple digital output but a mildly complex ling program. The codes for ESC and DELETE are signal output with a serial data component. In addi- unique, but TAB. RETURN, left arrow, right tion to these I/O capabilities, there are eleven serial arrow, down arrow, and up arrow produce code that I/O ports and four resistance sensitive timer is identical to that of CONTROL-I, CONTROL-M, inputs. CONTROL-H, CONTROL-U, CONTROL-J, and The speaker output is a serial output port con- CONTROL-K respectively. nected toa speaker through an audioamplifier. The The open Apple and close Apple keys are not asso- cassette input and output are serial data transmit- ciated with other keyboard functions. Instead, these ted via audio phone jacks on the motherboard are connected to the PBO and PBl serial inputs accessible from the back of the case. They are described in the nextsection. Pushing open Appleor designed to connect directly to the earphone output close Apple is equivalent to pushing pushbutton 0 or and microphone input of a common audio tape pushbutton 1 on a paddle set or .joystick, and these recorder. Firmware routines in motherboard ROM keys are mounted on the keyboard only to provide a read and write cassette data in Apple's storage convenient means of activating the PBO and PBl format. input lines. Usage of 5 % inch floppy disks is so prevalent that All ASCII produced by Apple He keypresses cassette storage is rarely used by most Apple owners. comes from the keyboard ROM which is a standard Floppy disk I/O is not a built-in capability of the 2K ROM. This ROM contains ASCII for a standard motherboard, so the disk electronics are contained keyboard layout and an alternate keyboard layout. in the drive and on a peripheral card called the disk The alternate layout is a Dvorak layout* in Ameri- controller. Disk data is transferred in parallel can Apple lie's. In export versions, it is usually a between the MPU and the controller, and serially layout tailored to the requirements of the host coun- between the controller and the drive. Control of disk try's primary language. The I/O requires an extensive program, and the most selected by installing a switchalternate layout can be assembly as shown in commonly used program of this nature is DOS 3.3 an application note at the end of Chapter 7. (Disk Operating System, version 3.3), a product of While there is no numeric keypad built into the Apple Computer, Inc. A more recently developed Apple He keyboard, there is a jack on the mother- DOS. and the one which is the current focus of sup- board which accepts a numeric keypad. Like ASCII port by Apple, is called ProDOS. from the main keyboard, ASCII from this external The other serial I/O signals are TTL (Transistor keypad comes from the keyboard ROM, so the keys Transistor Logic) compatible. TTL is a very com- of a keypad can be defined as desired by installing a mon logic family of integrated circuits used for dig- customized keyboard EPROM on the motherboard. ital logic. The logic devices on the Apple lie Other I/O motherboard are either TTLor interface di rectly to TTL,* TTL devices operate with two voltages cor- I/O is Input/Output. Our point of reference for responding tothe two states of digital logic. The th is d iscussion is the motherboard , mean ing that we "Most TTL chips in the Apple lie are LSTTL (Low Powered. Schottky-Barrier diode clamped TTL). The 6502, ROM, RAM. •Dvorak iskeyboard layoutdesi^ned to permitfaster typing than the MMU, the lOU. and the keyboard decoder are TTL compati- IS possible in the conventional QWERTY layout. ble MOS (Metal Oxide Semiconductor) chips. The Apple Ile— An Overview 1-11 TTL low voltage is 0 to 0.8 volts, and the TTL high (Direct Current) referenced to ground (0 volts). voltage is 2.4 to 5 volts. These are the two voltage Converting relatively high voltage, household AC levels vi^hich represent digital information through- power to the required low voltage DC power re- out the Apple lie. supply. quired bythe Apple He is the function of the power There is a 16-pin DIP (Dual In line Package) socket on the Apple He motherboard which is gen- The power supply in an Apple He is designed to erally called the game I/O connector. A set of two operate on the household power in the country in paddles, a joystick, or a resistive graphics pad is which it is sold. Inanycountry, the Apple He power normally connected here, but there is a capability supply generates +5, -5. +12, and -12 volts DC ref- for multiple uses. Four of the pins are annunciator erenced toground. These voltages are distributed outputs. These are output lines which can be inde- throughout the motherboard to any device that pendently switched to aTTL high or low level by the needs them. Additionally, all four voltages and controlling program. A fifth TTL output is called a ground are available at the peripheral slots to strobe. This output is high unless a program supply power to peripheral cards, and +5 VDC and triggers it. It then goes low for just 0.5 m icroseconds ground are available at the au.xiliary slot to supfily (halfofa 6502 cycle), then returns to its normal high power to an auxiliary card. state. There are three TTL input ports on the game I/O connector which can be read by a program. Two of SUMMARY these, PBO and PBl. are normally connected to pushbuttons on the joystick, paddles, or graphics The Apple He is a single board, (\^()2 based micro- pad. PBO and PBl are also connected to the key- computer with built-in nnemory and video genera- board open and close Apple keys respectively. Addi- tion circuitry. It is an improved version of the older tional y, ifthe motherboard X6 jumper is soldered, Apple II computer. Enhancements include full the SHIFT' line is connected to PB2 so that the left upper and lower case text handling capability, 80- and right SHIFT keys activate this third game I/O column text video display, and 128K of motherboard TTL input. and auxiliary slot RAM, as opposed to the upper The paddles themselves are just potentiometers case only, 40-column, 48K Apple II. (variable resistors). Joysticks are two potentiome- The Apple He circuit board contains seven pe- ters mechanically linked so that the resistance of one ripheral slots and an auxiliary slot which hold potentiometer represents horizontal motion and the smaller boards, and it is therefore thought of as a resistance of the other potentiometer represents motherboard. The slots give the Apple He expansion vertical motion. Game I/O graphics pads consist of and I/O capabilities comparable to more expensive X-ordinate and Y-ordinate resistive surfaces ar- card cage microcomputer designs. ranged and wired so that the X and Y resistances The motherboard can be one of two version.'^ — one vary with the point on the pad at which pressure is which outputs video that is color compatible with applied. the NTSC television system used in America, or one In addition to the game I/O socket, the four timer which outputs video that is color comi)atible with (paddle) and three TTL (pushbutton) inputs are the PAL television system used throughout western connected to a game I/O extension jack in the back Europe except in France. An Apple He in a given of the Apple He. This 9-pin jack provides a means of country will contain the version of the motherboard connecting a paddle set, joystick, or other device to compatible with that country's television system. the Apple He without lifting the cover. Further- Additionally, the video and keyboard RAM will be more, when a device is connected to this extension tailored to the requirements of that country's lan- jack, the game I/O lines which are not used by the guage or languages. extension jack device are available at the game I/O The 6502 in the Apple He operates at 1.0205 MHz. socket for connection to other devices. IRQ'. NMI', RESET, and READY signals to the 6502 are connected to the peripheral slots, The The Power Supply DMA' signal enables peripheral cards to isolate the MPU from the rest of the motherboard. This enables .^""^''hold power measures from 100 to 220 Volts control of the Apple He from secondary MPUs or At. (Alternating Current), depending on the coun- other DMA devices in the peripheral slots. MPU control of the various hardware features is via [J"^'""^^^J"^*! ^PPletheHe, househowever is located. Most of+5thecircui ts address decoding. , require volts DC 1 -1 2 Understanding the Apple lie 140 X 192 to 560 x 192 HIRES point mode in 15 The motherboard contains 65,536 bytes of dy- namic RAM, and motherboard circuitry fully sup- colors with color dependent resolution (DOUBLE- ports an additional 65,536 bytes of dynamic RAM in RES), and 560 x 192 HIRES point mode in black and white (DOUBLE-RES). Some capabilities exist an auxiliary slot RAM card. 16,128 bytes of firm- for mixing text and graphics. ware include Applesoft BASIC and a system moni- tor containing a number of important utilities. The video display in all modes is mapped in cer- In addition to the MPU, RAM, and ROM, there tain areas of RAM, motherboard RAM in the SINGLE-RES modes, and both motherboard and are three important special purpose ICs that im- plement Apple He motherboard logic functions. The auxiliary card RAM in the DOUBLE-RES modes. MMU controls the overall configuration of the lOU circuitry continuously scans one of four possi- Apple lie memory map; the lOU performs multiple ble areas in motherboard and auxiliary card RAM functions related to generation of the video display while RAM output is processed to generate video. and other I/O; and the timing HAL contains most of RAM addressing is time shared between the system the circuitry required for the generation of Apple address bus and the lOU video scanner. 6502 access He timing signals. The controlling MPU program to RAM alternates with video scanner access so, manipulates overall memory configuration, the while the 6502 operates at 1 MHz, motherboard and auxiliary card RAM are accessed at 2 MHz. In the video display mode, and some I/O functions by set- tingor resetting programmable MMU and lOU soft processof scanning RAM for video output, the RAM switches. is refreshed. The video output is compatible with a video In addition to video output and the I/O capabili- monochrome or color monitor. It can be used with a ties inherent with the peripheral slots, there are a home TV when connected through an inexpensive cassette input port, a cassette output port, a speaker, modulator. Either single or double horizontal reso- four TTL control outputs, one .5 microsecond TTL lution displays can be produced by programs, al- outputstrobe, four resistance sensitive timer inputs, though an auxiliary slot RAM card is necessary for three TTL inputs, a keyboard, and a numeric key- use of the DOUBLE-RES display modes. All pad jack. Two of the TTL inputs can be activated by DOUBLE-RES displays are available with a 64K pressing the open or close Apple switches on the auxiliary RAM card, but a IK RAM card only keyboard. supports DOUBLE-RES text or, with a minor The keyboard contains 63 key switches arranged RAM card modification. DOUBLE-RES LORES like those on an IBM SelectHc typewriter, and is graphics. adequate for most text processing functions. Opera- TEXT is upper and lower case, 5x7 dot matrix tional features include a CAPS LOCK key, n-key representation in a40character by 24 line (SINGLE- rollover, and automatic simulation of rapid key- RES), or 80 character by 24 line (DOUBLE-RES) presses when a key is held down (auto repeat). An display. There are 96 video text characters, all of alternate keyboard layout is electrically selectable, which can be displayed normally (white on black) or but a switch assembly must be installed to access the inverted (black on white). Sixty-four of the text alternate layout. Also, because of the versatile characters can be flashed between normal and nature of the motherboard keyboard circuitry, the inverse display. This includes numerals, punctua- keyboard layout can be changed by simply replac- tion, and upper case alphabetic characters but ing aROM on the motherboard. excludes lower case alphabetic characters. The built-in Apple lie power supply provides +12, Graphics modes include 40 x 48 (SINGLE-RES) —12, +5, and —5 volts DC referenced to ground. and 80 x 48 (DOUBLE-RES) LORES block modes These voltages and ground (0 volts) are distributed in 15 colors, 140 x 192 HIRES point mode in six throughout the motherboard and to the seven pe- colors (SINGLE-RES), 280 x 192 HIRES point ripheral card slots. -i-5 volts and ground are also mode in black and white (SINGLE-RES), 140 x 192 connected to the auxiliary slot. HIRES point mode in 15 colors (DOUBLE-RES), chapter 2 The Bus Stnicture of the Apple lie There are many signals distributed throughout are collectively referred to as a bus. Physically, the Apple He, but the most fundamental data then, a bus is an electrical distribution of multi- transfer lakes place on the data bus, and the most line information. In the Apple, the address bus is basic control information is distributed via the a sixteen-line electrically distributed information address bus. To understand how the Apple He and group, and the data bus is an eight-line electrically other microcomputers really work, it is very impor- distributed information grouji. tant to understand the bus structure. Fortunately, Some devices connected to a bus are strictly it's not that hard to understand. The basic concepts receivers of information. ROM is like this in its con- of the bus structure are within the grasp of nearly nection tothe address bus. Receivers respond to the everyone who uses a microcomputer. high/low information on the lines of the bus without The bus structure is a natural starting point for appreciably affecting the bus information. Electri- learning what really goes on inside the Apple com- cally speaking, the receiver input presents a high puter, Discussing the bus structure will lead natu- impedance to the bus which enables other devices to rally to the discussion of the other microcomputer bring the bus lines high or low. If impedance is a elements that the bus is connected to. First, though, new word to you, it may help to think of high imped- we need to find out what a bus is and how it is used. ance as high isolation. Some devices on a bus must be information COMPUTER BUSES AND transmitters capable of bringing the bus lines high or low. If more than one information transmitter is THREE STATE LOGIC connected to a bus, each transmitter must be able to Logic signals in the Apple are distributed electri- disconnect itself from control of the bus by present- cally via conductive paths on the motherboard. ing ahigh impedance to the bus. Only one device can When a number of signals are grouped functionally control the bus at a time. Instead of two state, the and distributed throughout a microcomputer, they outputs of these devices are said to be three state or 2-2 Understanding the Apple lie tri-state. The three states are high voltage, low volt- sion of the address bus controlling the direction of age, and high impedance. All information transmit- data flow on the data bus. Communication takes ters to the data bus of the Apple are capable of place on every 6502 cycle between the MPU and an presenting these states to their bus connections. The add ressed device. Data flows between the MPU and ROM output to the data bus is a typical three state the device in a direction determined by the R/W output. line. The MPU controls the R/W' line and the A third type of device, capable of transmitting to address bus. or receiving from a bus, is called a transceiver Figure 2. 3 shows the two types of bus access which (transmitter/receiver). The MPU, for instance, occur in the Apple He. In a read access, the MPU receives (reads) data from and transmits (writes) places an address on the address bus and reads the data to the data bus, so as far as the data bus is data bus. In a write access, the MPU places an concerned, the MPU is a transceiver. While the address on the address bus and places data on the MPU is reading, it presents a high impedance to the data bus. This establishes a system of data bus con- data bus so the addressed device can place data on trol that had to be implemented in the design of the the data bus. While the MPU is writing, it controls Apple. The control system works like this: the data bus. Figure 2.1 shows a hypothetical 4-line bus. The 1. When the R/W' line is low (write access), all symbols shown are schematic representations of a inputs to the data bus are disabled except the MPU. tri-state line driver, a line receiver, and a line trans- ceiver. Atriangle represents a single line driver. 2. When the R/W' line is high (read access), all TViangles with a control linecomingin from the side inputs to the data bus are disabled except the device which is addressed. are tri-state line drivers. A little circle at a control input to a triangle means that the input is active This system concept keeps traffic flow orderly and is when its voltage is low. Here is a truth table for the a basic feature of microcomputer design. tri-state line driver shown in Figure 2,1: The only remaining points to be made about buses OUTPUT involve semantics. The peripheral slots are some- INPUT ENABLE OUTPUT times referred to as the peripheral bus or the Any Low High Impedance Apple bus. In fact, the wiring of the slots fits our High High High description of a bus as a functional group of distrib- Low High uted signals. The slots are a bus whose distributed Low ■ signals include the address bus. the data bus, and The control line either enables the high/low output other signals. Up to this point, the discussions have or forces the output to high impedance. The high/ avoided calling the slots a bus only to avoid confu- low output, when enabled, follows the input. sion between the card cage bus and the more basic It can be seen that the output enable controls of address bus and data bus. The connections to the the various information transmitters are the key to RAM and ROM chips form two more distributed cohesive control of the bus. For a bus with many signal groups that can be referred to accurately as possible information transmitters, like the data bus the RAM bus and the ROM bus. This book will of the Apple, there has to be some intelligent man- continue to use the word "bus" to refer to the address agement ofthe various tri-state output enables. We bus, the data bus, and the extensions of these two will see shortly how this is accomplished. In the basic communications paths. The peripheral bus, foUowingdiscussions, remember that when a device RAM bus. ROM bus. and other distributed signals like a ROM chip responds to an address prompt by will be referred to using other terminology. placing data on the data bus, this is accomplished The lines of the various buses in the Apple are via an output enable to the tri-state outputs of the referred to by one or more letters followed by a ROM chip. number. For example, the lines ofthe Apple address Figure 2.2 shows a highly simplified diagram of bus are referred to as AO through A15. The largest the bus structure of the Apple lie. There are two number, A15 in this example, refers to the line distinct multiline signal paths: the address bus and which carries the most significant bit of informa- tion. Alist the data bus. The R/W' line (Read/Write control) is shown separate and can be thought of as an exten- follows here. of bus terminology used in this book The Bus Structure of the Apple lie 2-3 OUTPUT ENABLE LINE DRIVER Information is transmitted to the bus by a device with tri-state outputs. LINE RECEIVER An information receiver presents a high impedance to the bus. LINE TRANSCEIVER A bidirectional connection to the bus must present a high impedance to the bus when in receive mode. Figure 2.1 A Hypoth«fical Four-Line Bus. 2-4 Understanding the Apple lie ADDRESS BUS DATA BUS AND R/W R W ROM W R Figure 22 Battc MIcrocompuTer Building Blocks. The Bus Stiuctur© of the Apple lie 2-6 MPU MPU BUS ADDRESS DATA ADDRESS BUS BUS ADDRESSED ADDRESSED DEVICE DEVICE A READ CYCLE A WRITE CYCLE Figure 2 3 Communication on the Bus S^tem. programming, but it is very much like the way a LINE microcomputer works. NAME OF BUS TERMINOLOGY The analogy goes like this. A computer is like a Address A0-A15 Data gigantic row of pigeonholes with pieces of paper in MD0-MD7* them. Each piece of paper has an instruction on it. Multiplexed RAM address RA0-RA7 There is a man who goes to each pigeonhole, one Auxiliary RAM data AUXD0-AUXD7 after the other, reading the instructions and doing Video data VID0-VID7 what they say. The man always gets the next Peripheral slot data DO— D7 instruction from the next pigeonhole in the row By this time the reader should understand the unless an instruction tells him to go to some other conceptof thebusasacommunication path. We will pigeonhole. now move on to how microcomputers in general and That's the pigeonhole computer. The man is exe- Apples in particular perform their functions in a cuting astored sequential program. The man is the bus environment. microprocessor. The row of pigeonholes is computer memory. The instructions are the program. The microprocessor is smart enough to sequence through THE PIGEONHOLE COMPUTER memory and do what it's told, but it has to be told. It There is an old analogy for understanding digital has to have a program. wwnputer operation which you don't see often enough •MD in MDO— MD7 stands for the MOS Data bus. Apple chose in personal computer instruction literature. It pos- this nomenclature because nnost of the ICs connected to IMDO— sibly ISnot that helpful for understanding BASIC MD7 are MOS ICs. 2-6 Understanding the Apple lie THE MPU, RAM. AND ROM $400 just as sure as your mailbox has a unique mail- ing address. Inside RAM, inside ROM, all along the The microprocessor is the engineering marvel address bus, address decoding takes place every which made all the home computers possible. The 6502 cycle to enable only one of 65536 possible 6502 MPU is what executes the programs in the addresses. Apple. Viewed from the outside, its capabilities The 6502 is continually executing a program include manipulation of the address bus and R/W while power is applied. If it gets lost and tries to (Read/Write') control, writing data to the data bus, execute a program where no program exists, it reading data from the data bus, logical and arith- interprets whatever jibberish is appearing on the metic manipulation of data, and response to various data bus as a program and executes it anyway. An control inputs. All of these add up to execution of a unstoppable program-executing machine like this sequential program that comes from the data bus. has to have a starting point when you turn the com- You see, the man from the pigeonhole computer puter on. It also needs a way to start from scratch resides inside the MPU. The iittle guy has this con- when it gets lost. This starting-point is the RESET' trol line called R/W, and he can put any address from 0 to 65535 on the address bus. He uses the R/W input to the 6502. The RESET' input to the 6502 goes low when the line to tell the outside world whether he's reading RESET key is pressed, when a peripheral card from or writing to the data bus. He uses the address makes it go low, or when the computer is turned on. bus to tell the world where he wants the read data to Any one of these occurrences makes the 6502 stop come from and the write data to go to. There are what it's doing, load the address of the next program plenty of things this man can do, but his most favor- step from locations $FFFC and $FFFD, and start ite thing in the whole world is to increment the executing at that address. The contents of $FFFC address bus and read the results on the data bus. and $FFFD are the low and high bytes of the reset While he's reading, this little workaholic interprets the data he reads as instructions. If there is an out- The $FFFC/$FFFD reset vector comes from side device that is responding to his address prompts motherboard ROM since the high RAM is disabled with a valid sequential program, he will flat out vector.'* for reading by the reset sequence. In Apple He execute the program. This means that you can ROM, the contents of $FFFC/$FFFD is ?FA62, the exploit his insatiable reading appetite and get him address of the firmware reset routine. There are to do what you want if you're smart enough. That's several important aspects of this routine that de- all any microcomputer designer ever really expects termine features of the Apple lie, but the important from an MPU. The key requirement above was an outside device point here is that the Apple has a power-up routine in ROM. This is an essential feature of microcom- responding to the address prompts. This device is puter design. You might say it guarantees that the memory: ROM or RAM. All of the addressing on the 6502 always gets out of bed on the right side. Apple address bus is parceled out to various devices. Another routine which a microcomputer always RAM gets addresses $0— $BFFF. ROM and high has in ROM is a routine to load data from a storage RAM share $DOOO-$PFFF, although this range is device into RAM so that execution of saved pro- thoughtof asbeingprimarily assigned to ROM. The grams ispossible. The Apple lie, however, has much peripheral slots are controlled by $C090— $CFFF. more than the bare necessities in its 16K of ROM $C000— $C08F is divided up among the keyboard space. The naked Apple is a cassette based system in and cassette and all the other built-in devices. If the which BASIC in ROM and a system monitor in 6502 happens to be executing a program in the ROM prevent unnecessary user aging while wait- $D000— IFFFF range with high RAM disabled, ing for the computer to become operational at turn then ROM is responding to the addressing with a on. Additionally, firmware diagnostic routines are series of data which the 6502 is interpreting as a available to confirm correct operation or aid in fault program. If the ROM program tells the MPU to isolation in case of hardware failure. store a byte of data at $400, the MPU takes a microsecond to bring R/W low, set the address bus •Two 8-bit RAM locations are required to store a 16-bit 6&02 to $400, and place the pertinent data on the data bus. address. The 6502 fetches a 16-bit address from an adjacent pair of memory locations. The less significant byte of the address is The data is accepted by address location $400 which fetched from the lower memory location, and the more signifi- is in RAM. That pigeonhole of RAM owns address cant byte is fetched from the higher memory location. The Bus Structure of the Apple He 2-7 RAM ADDRESSING AND RAM is addressed with a one-two punch. First, half DATA DISTRIBUTION of the address information is input to RAM where it is saved. Then the second half of the address infor- Wfiile Figure 2.2 adequately depicts the funda- mation isinput and the data access takes place. Both mental MPU access to RAM, it does not show many the first half and the second half of the address are details of the layout of RAM in the Apple. In fact, input on the same eight pins of RAM, so sixteen bits there is some complexity to RAM access. This is due of information from the address bus must be multi- to the nature of the dynamic RAM chips, the dual plexed onto eight lines to effect the one-two punch. access to RAM from the MPU and the video scanner, This multiplexing is accomplished in the MMU, and the multifaceted bank switching of RAM that and the multiplexed MPU address is distributed occurs in the Apple He. Figure 2.4 is the partial from the MMU to all RAM chips on the mother- diagram of the Apple lie's bus structure, expanded board and auxiliary card via the 8-line multiplexed from Figure 2.2 to show more of the details of RAM address bus (RAO— RA7). address and data distribution to RAM. The thick The two halves of dynamic RAM addressing are black and dark gray lines in Figure 2,4 represent referred to as the ROW address and the COLUMN the multiple lines of the address bus and the data address. This refers to conceptual rows and columns bus, respectively, R/W is considered to be distrib- of memory cells inside the RAM chips. uted with the address bus. The MPU, as before, is in The RAM addressing would be complex enough, control of the address bus. but in the Apple, the RAM address lines are doubly A 64K RAM card is shown installed in the auxil- multiplexed. Both the MPU and the video scanner iary slot in Figure 2.4. This reflects the fact that the in the lOU must access RAM, so the multiplexed Apple lie design supports 128K of RAM and an RAM address is connected to the lOU as well as the 80-column text display. Eighty columns of text and MMU and the RAM chips, Duringevery 6502 cycle, 128Kof RAM are fully implemented in timing, con- first the video scanner output, then the addre.ss bus trol, and bus structure. They just forgot to mount the contents must be switched on to the multiplexed auxiliary RAM on the motherboard. RAM address bus. Each access is accomplished in Figure 2,4 also shows some secondary buses which two halves (the one-two punch). The RAM address carry address information or data. These buses are multiplexing is cyclical, resulting in the following not connected directly to the address bus or data repeating pattern of access to the multiplexed ad- dress bus: bus, but they can be thought of as extensions of the address bus or data bus. The light gray buses are Tl -Video ROW address (lOU) extensions of the data bus, and the medium gray bus T2 -Video COLUMN address (lOU) is the multiplexed RAM address bus, an extension T3 -MPU ROW address (MMU) of the address bus. T4 -MPU COLUMN address (MMU) The Multiplexed RAM Address Bus The lOU connection to the multiplexed RAM address bus is bidirectional. While the video scanner The multiplexed RAM address bus is a solution to is addressing RAM, the lOU transmits the video acommon problem in VLSI (Very Large Scale Inte- ROW address then the video COLUMN address to gration) ICpackaging. The problem is that you can pack such complex and extensive logic functions the RAM address bus. While the MPU is addressing RAM. the lOU monitors the RAM address bus and into a small IC that there are not enough pins on the IC to input and output all the information required receives MPU address information. More specifi- to support the logic functions. The solution is to cally, the lOU latches (saves) RAO— RA6 of the multiplex (switch, share) the information. In the MMU ROW address and thus monitors AO— ASand A7 of the address bus without direct connection to case of Apple RAM, this means multiplexing the the address bus. By this sleight of hand, the need for information of the sixteen lines of the address bus onto the eight lines of the RAM address bus. seven pins on the lOU is eliminated. We don't want to get too steeped in RAM address- *ThrouRhout this book the word "cell" will be used to refer to a ing right now, but the basic situation is that there unit of memory that stores one bit of data. The word "location" are not enough pins on a 64K dynamic RAM chip to will be used to refer to eight associated memory cells that hold address 64K memory cells simultaneously.* The one byte of data in the Apple He. 2-8 Understanding the Apple lie DATA BUS MD0-MD7 ADDRESS BUS (AO-A 15) ANDR/W MPU RAO-RAT D3 RAMI |RAM| pAM| |RA' Al MAIN lOU LATCH EXT VIDEO t VIDO-7 VIDEO GEN MU FROMM AUX LATCH D6 □3 AUXO-? D6 D7 ^ W R RAM RAM RAM RAM RAM RAM RAM RAM I £N80' D4 R/W ROM ADDRESS BUS OE' RAM ADDRESS BUS DATA BUS DATA BUS EXTENSION Figure 2A Bus Diagram: RAM Addressing and Data Distribution in ttie Apple lie. The Bus Structure of the Apple lie 2-^ Video Scanning organized 64K x 1, meaning that each RAM chip has The video scanner is not connected to the address 65,536 1-bit memory cells, one data input line, and bus and is therefore not controllable by the MPU. one tri-state data output line. 6502 microprocessor The scanner is a free running counter inside the structure requires that memory be organized for lOU, completely isolated from program control, 8-bit parallel data transfer, so eight chips provide that shares RAM on an equal footing with the 6502. 65,536 8-cell memory locations in a 6502 system. The scanner is like a second MPU, but much simpler Each of the eight motherboard RAM chips is than an actual MPU. In microcomputer jargon, it is associated with one line of the data bus. The input a built-in DMA device performing simultaneous and output lines of one chip are tied to MD7, the direct memory access with the MPU. input and ouput lines of another are tied to MD6, etc. Video scanner access to RAM is a read access as The eight RAM chips can thus be thought of as a opposed to a write access, but it is of a different single 64 kilobyte memory device with eight input/ nature than MPU read access. The M PU reads data output lines connected directly to the data bus. The from RAM, meaning that the MPU addresses RAM, R/W line is gated to the RAM chips when it is time and data from RAM comes back to the MPU. In to pass data to or from the MPU, .so the RAM chips contrast, when the video scanner addresses RAM. are able to receive data on MPU write cycles and the data from RAM does not come back to the transfer data on MPU read cycles. The RAM read/ scanner. The data goes out, instead, to the video write control line is always forced to read when the generator for video processing and, in the case of video scanner isaccessing RAM, so the video scanner motherboard RAM when R/W is high, to the peri- always reads, never writes. pheral slots via the data bus. As a result, this book There is a device connected to the data bus which does not refer to the video scanner as reading data does not communicate with the MPU. It is the from RAM. Instead, the video scanner is said to motherboard video latch. This latch receives data drive data out of RAM to the video data latches and from the data bus at a point in time when data from the peripheral slots. the video scanner access to RAM is on the bus. In a Other than the fact that the video scanner and sense, then, the data bus is multiplexed. Data travels between the MPU and RAM during MPU access, MPU both address RAM, their only operational tie and data travels from motherboard RAM to the is timing. Just as the 6502 executes a machine cycle motherboard video latch during video scanner once every microsecond, the video scanner changes access. its memory address, and accesses RAM once every The latched video data is routed, via the video data microsecond. Logically enough, the timing for the bus, to video generation circuitry both internal video scanner and MPU originate from the same (VID6-VID7) and external (VID0-VID5) to the source. In fact, all timing on the motherboard origi- nates atthe same source. The timing involved in the lOU. It is proces.sed there to produce the dot pat- terns that make up the Apple He display. VID7 is sharing of RAM is quite elaborate and is covered in also routed to the timing generator where it is u.sed the chapters on timing generation, RAM, and video todeterminewhether or not groups of seven HIRES generation (Chapters 3, 5, and 8). dots are slightly delayed. The output of the video scanner is used in the lOU Auxiliary RAM data paths are similar to mother- for other tasks besides addressing RAM. It is used to board data paths with one bigdifferenee. The auxil- makeupanumberoflOUoutputsrequired in video iary RAM data inputs and outputs are not connected generation. This includes the syne portion of the directly to the data bus. They are isolated from the VIDEO signal, so the television scan is syncronized data bus by a bidirectional bus driver that only With the scanning of RAM. Video scanner outputs enables data transfer when the MPU is reading are also used in Apple timing generation. MIXED from or writing to auxiliary RAM. This creates an mode switching between GRAPHICS and TEXT, switching between normal and inverse video to auxiliary RAM data bus (AUXDO— AUXD7) which is an extension of the motherboard data bus. create flashing text on the screen, simulating re- During video scanner access to auxiliary RAM, the peated keypresses for the keyboard auto-repeat motherboard data bus is isolated from the auxiliary function, and timing out the power-up reset. RAM data bus. There is a latch connected to the auxiliary RAM RAM Data Distribution data bus which saves the data resulting from the The 65,536 bytes of motherboard RAM consist of video scanner access to auxiliary RAM. Like the eight 64K dynamic RAM chips. Each RAM chip is motherboard latched video data, the auxiliary 2H0 Understanding the Apple lie v.deo bu to he bus and R/W' line are the way in which the 6502 latched video data is routed on the commands the Apple devices to do things. There are proc essi ng to make up the video generator for logic circuits in the MMU, the lOU, and some the moftertoard vfDES signal auxi of the Apple^Bohave liary latch th tr>-state outputs smaller ICs on the motherboard that detect certain latch and the is such that the addresses or address ranges, then perform control to the video bus, and Apple timing s to various func- two latches alternate in cont roll ing the video bu. functions or output control signalfollow ing types of in scan ning RAM for video tional areas of the Apple. The The timing involved decode : chap ter But control are performed by address output is too complex to cover in this from ^oi should be able to get the gene ra pict ure 1. Gating (enabling) of information to the data cycl e befo re Figure 2.4. In the first half of the MPU with the data bus including data from serial inputs, periph- it is time for the M PU to comm unic ate access to eral slots, ROM, RAM, the MMU. and the IOU.» bus, the video scanner performs a read ltan eous ly in 2. Direct control of serial output lines. RAM This access is performed simu y RAM and the 3. Control of peripheral slots. motherboard RAM and auxi liar en out 4. Control of display mode soft switches in the data and auxi liar y data are driv motherboard kno wn data is together. At a moment when the vide o nd the 5. Control of memory management soft switches to be valid on both the motherboard data busa hed in in the MMU. o data is latc auxil iary RAM data bus, the vide the motherboard and auxiliary video latches, hor Control by address decode gives cohesion to the bus rose cond , the auxi liar y video structure. the foll owin g half -mic data is presenton the video bus for processi ng by the The address and control functions of the address of video generator. Foll owin g that, moth erbo ard video bus are not separate entities but different w^s o bus for one half -mie ro- looking at the same thing. Addressing memor y loca- data is present on the evide second At the end ofth second half-microse data cond, a tion $95FF can be thought of as controlling that te new set of video data is latched in the pair of memory location. Similarly, control of the casset lay it. The latches. If the Apple is in a DOUBLE-RES disp output line may be thought of as addre ssing mode, the vide o gene rato r proc esse s auxi liar y and address bus could be called the control bus motherboard video data atone half-microsecond per Figure 2.5 is a partial diagram of the Apple He s video cycle. If the Apple is in a SINGLE -RES dis- bus structure highlighting the address de(»ding play mode, the vide o gene rato r igno res the auxil lary motherboard devices. Please refer to this figure data and processes the motherboard data at one during the following discussion. microsecond per video cycle. The primary address decoding circuitry of the motherboard is in the MMU. It alone, of the address ADDRESS DECODING decoding elements, monitors all 16 lines of the address bus. The MMU monitors the entire $0000- Inside RAM and ROM, some pretty sophisticated $FFFF 6502 address range, and activates the other address decoding goes on so thatlocation data communica- address decoding elements via various control sig- tion iswith the correct memory . Each RAM nals. Each ROM chip, for example, is capable of chip in the Apple He has a capacitation, y of 65536 indi- decoding a range of 8192 addresses, but the MMU vidually accessible bits of inform and each must tell the ROM chip that it is enabled and an ROM chip has a capacity of 8192 individually address in its particular range of 8192 addresses is accessible bytes of information, Needless to say, on the address bus. Because it receives an enabling much of the circuitry in the memory chips is devoted input from the MMU, ROM does not have to monitor to decoding the address input. all 16 lines of the address bus. It just monitors AG— Like memory, but on a much smaller scale, the A12 which is enough to decode a range of 8192 Apple must decode addresses to control its various addresses. Similarly, other address decoding ele- functions. As has been stated previously, the address ments such as the peripheral decoding circuits and •When a digital signal controls the passage of information in a •As will be seen in Chapters 3. 5. and 8, this moment is PHASE 0 logic device, it is said to gate that the information. Gating of infor- rising. Peripheral cards can also latch the motherboard video mation islike opening or closing gate of a fence to control data using PHASE 0 rising. passage through the gateway. The Bus Structure of the Apple Ile 2-1 1 ADDRESS BUS DATA BUS ANDR/W MPU MD7 -CASEN' (MOTHERBOARD RAM) -ENeO'(AUXIL(ARYRAM) DATA ■ROMENI'(CI-DFROM) y GATES BUS -R0MEN2'(E0-FFR0M) 'KBD' (KEYBOARD) -MD IN/OUT' (PERIPHERAL DRIVER DIRECTION) I/O STROBE' SEVEN I/O SELECTS' SEVEN DEVICE SELECTS RAM C04X'(C040 STROBE') C06X' (SERIAL INPUT) C07X' (TIMER TRIGGER) A0-A5 and A7 are transmitted SPKR TO SPEAKER AMP from the MMU to CSSTOUT TO CASSETTE OUTPUT the lOU on the RAM address AN0-AN3T0GAME I/O SOCKET bus. MD7 ROM ADDRESS BUS RAM ADDRESS BUS DATA BUS Figure 25 Bus Diagram: Address Decoded Signals in the Apple fie. 2-12 Understanding the Apple He driver as described in the next section. CXXX en- the lOU do not have to monitor the full address bus ables further address decoding in the $CXXX range because they receive enabling inputs directly or in the peripheral address decoding circuitry. indirectly from the MMU. The Apple management The signals output by the peripheral address decod- signals, decoded from the address bus and output from the MMU. are listed here. ing circuitry are SIGNAL FUNCTION • an I/O STROBE' signal to the seven pe- Enable data transfer ripheral slots, CASEN' between motherboard RAM • an I/O SELECT' signal to each of the and MPU peripheral slots, Enable data transfer • a DEVICE SELECT' signal to each of the EN80' between auxiliary card peripheral slots, RAM and MPU • the C040 STROBE' output, • the C06X' serial input enable signal, Enable Cl-DF ROM ROMENl' Enable EO~FF ROM • the C07X' timer trigger, cxxx R0 MEN2' Enable I/O address decoding • and the COXX' signal to the lOU. Enable keyboard The I/O STROBE', I/O SELECT', and DEVICE ' OUT' Control direction of SELECT' signals are used by the peripheral slots in KBDIN/ MD bidirectional peripheral data a variety of ways described in Chapters 6 and 7. In bus driver many instances, the effect is to enable data bus communication with a peripheral card. The C040 Other address decoding takes place in the MMU which does not directly manipulate these control STROBE' is a game I/O socket output that goes low for one half of a microsecond when $C04X is on the signals. This includes setting and resetting of mem- address bus. C06X' enables one of eight serial inputs ory configuration soft switches and enabling the status of soft switches to MD7 of the data bus for to MD7 of the data bus during a read cycle. C07X' triggers the four timers whose durations depend on reading by tine MPU. For example. $C082 on the address bus is decoded inside the MMU to reset the settings of paddles, joysticks or other variable resis- HRAMRD (high RAM read enable) soft switch. tors. The COXX' signal enables further address dec- oding inthe lOU. With this soft switch disabled, an MPU read to Address decoding in the lOU is not as extensive as address $F000 will result in the MPU bringing it is in the MMU. The lOU only monitors parts of the R0MEN2' low and subsequent transfer of data $C0OO— $C05F range to set or reset some video con- from the EO— FF ROM to the data bus. The func- figuration soft switches, to gate the status of various tional details of the MMU soft switches are not of lOU flags and soft swithches to MD7 of thedatabus primary interest here but are a subject of Chapter 5. for reading by the MPU, and to directly control The important concept here is that the controlling some serial outputs. The serial control signals which 6502 program manipulates the memory configura- come from the lOU are tion ofthe Apple by address bus commands decoded in the MMU to set or reset soft switches. Then the • socket, ANNUNCIATORS 0-3 to the game I/O MMU, guided by the status of the soft switches, monitors the address bus and enables various func- • SPKR to the speaker amplifier, tional areas of the Apple via the control signals • and CASSO to the cassette output voltage listed above. divider. All of the MMU management signals except MD Figure 2.5 shows that the only line of the address IN/OUT' and CXXX enable the selected device to bus connected to the lOU is A6. Even with the aid of control the data bus during a read cycle or, in the case of RAM, to receive data from the data bus the COXX' input, the lOU needs more addressing inputs to perform its decoding functions. It needs to during a write cycle.* MD IN/OUT' controls the monitor AO to distinguish between a switch on and direction of a bidirectional peripheral data bus switch off function. It needs to monitor A3 to distin- guish between a video soft switch command and an •Some terminology examples—JCXXX is the address range annunciator command. In fact, to perform all of its $C000— $CPFF. CXXX is a signal which goes high when an address in the $CXXX range is on the address bus. C06X' is a decoding functions, the lOU needs to monitor AO— signal which goes low when an address in the $C06X range is on A7 of the 6502 address in addition to monitoring the the address bus. COXX' line. However, with the exception of A6, it The Bus Structure of the Apple He 2-13 Table 2.1 Apple Me Master Address Decode Table (1 of 2). HEX DECIMAL DECIMAL FUNCTION RW RANGE RANGE COMPLEMENT RESET/SET 80STORE W -16384/-16383 $COOO/$C001 49152/49153 RESET/SET RAMRD w $C002/$C003 49154/49155 -16382/-16381 RESET/SET RAMWRT w $C004/$C005 49156/49157 -16380/-16379 RESET/SET INTCXROM w $C006/$C007 49158/49159 -16378/-16377 RESET/SET ALTZP w $C008/$C009 49160/49161 -16376/-16375 RESET/SET SL0TC3R0M w $C0OA/SCO0B 49162/49163 -16374/-16373 RESET/SET 80COL w $COOC/$COOD 49164/49165 -16368 -16372/-16371 RESET/SET ALTCHRSET w $COOE/$COOF 49166/49167 -16370/-16369 READ KBD/KEYSTROBE R 49152-49167 -16384 -16368 TO -16369 RESET KEYSTROBE RW $COOX 49168 -16367 RESET KEYSTROBE w $C010 49168-49183 -16368 -16366 TO -16353 READ KBD/AKD R $C01X 49168 -16365 49169 READ KBD/HRAM BANK2 R $C010 -16364 READ KBD/HRAMRD R icon 49170 -16363 READ KBD/RAMRD R $C012 49171 -16362 49172 READ KBD/RAMWRT R $C013 -16361 READ KBD/INTCXROM R $C014 49173 -16360 49174 READ KBD/ALTZP R $C015 -16359 $0016 49175 -16358 READ KBD/SLOTCSROM R READ KBD/80STORE R 49176 -16357 $C017 -16356 R $C018 49177 READ KBD/VBL' 49178 -16355 READ KBD/TEXT R $C019 READ KBD/MIXED R $C01A 49179 -16354 $C01B -16353 READ KBD/PAGE2 R 49180 READ KBD/HIRES R $C01C 49181 READ KBD/ ALTCHRSET R $C01D 49182 READ KBD/80COL R 49183 $G01E -16352 TO -16337 TOGGLE CASSETTE OUT ICO IF 49184-49199 TOGGLE SPEAKER RW $C02X 49200-49215 -16336 TO -16321 RW $C03X 49216-49231 -16320 TO -16305 C040 STROBE' RW -16304/-16303 RESET/SET TEXT RW $C04X 49232/49233 $C050/$C051 -16302/-16301 RESET/SET MIXED RW $C052/$C053 49234/49235 -16300/-16299 RESET/SET PAGE2 $C054/$C055 49236/49237 RESET/SET HIRES RW -16298/-16297 RW $C056/$C057 49238/49239 -16296/-16295 RESET/SET ANO $C058/$C059 49240/49241 -16294/- 16293 RESET/SET ANl RW $C05A/$C05B 49242/49243 RESET/SET AN2 -I6292/-16291 RW RW $C05C/$C05D 49244/49245 -16290/-16289 RESET/SET AN3 $C05E/$C05F 49246/49247 -16288.-16280 READ CASSETTE IN R RW 49248,49256 READ PBO $C060.$C068 -16287,-16279 R $C061,$C069 49249,49257 READ PBl -16286,-16278 R $C062,$C06A 49250,49258 READ PB2 -16285,-16277 R $C063,$C06B 49251,49259 READ TIMERO R 49252.49260 -16284,-16276 READ TIMERl $C064,$C06C -16283,-16275 R $C065.$C06D 49253,49261 READ TIMER2 R 49254,49262 -16282,-16274 READ TIMERS $C066,$C06E -16281,-16273 R 49255.49263 TRIGGER TIMERS $C067.SC06F -16272 TO -16257 RW 49264—49279 SC07X *(i.!> 2-14 Understanding the Apple lie Table 2.1 Apple He Master Address Decode Table (2 of 2). DECIMAL HEX DECIMAL COMPLEMENT FUNCTION RANGE RANGE RW HIGH RAM, BANK2 -16256,-16252 WCNT = O.W',R R 49280,49284 -16255.-16251 RW $C080,$C084 49281,49285 WCNT+1,R' W -16255.-16251 $C08L$C085 49281,49285 WCNT = 0 R' $C08L$C085 49282.49286 -16254,-16250 WCNT = 0,W',R' R $C082,$C086 -16253,-16249 WCNT+l.R RW 49283,49287 -16253-16249 W $C083,$C087 WCNT = O.R $C083,$C087 49283,49287 HIGH RAM, BANKI -16248,-16244 RW $C088,$C08C 49288.49292 -16247,-16243 WCNT = 0,W',R R $C089.$C08D 49289,49293 -16247,-16243 WCNT+1,R' W 49289,49293 WCNT = O.R' $C089,$C08D -16246,-16242 $C08A.$C08E 49290,49294 -16245,-16241 WCN T = 0,W'.R' WCNT+l.R R RW 49291,49295 $C08B.$C08F -16245,-16241 WCNT = 0,R W 49291,49295 RW $C08B,$C08F -16240 TO -16225 DEVICE SELECT' SLOT 1 49296—49311 "16224 TO -16209 DEVICE SELECT' SLOT 2 $C09X 49312—49327 RW $COAX -16208 TO -16193 DEVICE SELECT' SLOT 3 RW 49328—49343 -16192 TO -16177 RW $COBX 49344—49359 DEVICE SELECT' SLOT 4 $COCX -16176 TO -16161 DEVICE SELECT' SLOT 5 RW 49360-49375 $CODX 49376-49391 -16160 TO -16145 DEVICE SELECT' SLOT 6 -16144 TO -16129 RW RW $COEX 49392-49407 DEVICE SELECT' SLOT 7 $COFX -16128 TO -15873 RW 49408-49663 1/0 SELECT' SLOT 1 $C1XX -15872 TO -15617 I/O SELECT' SLOT 2 RW 49664-49919 I/O SELECT SLOT 3 $C2XX 49920—50175 -15616 TO -15361 RW $C3XX 50176-50431 -15360 TO -15105 I/O SELECT' SLOT 4 -15104 TO -14849 RW $C4XX 50432-50687 I/O SELECT' SLOT 5 $C5XX -14848 TO -14593 I/O SELECT' SLOT 6 RW RW 50688—50943 $C6XX 50944-51199 -1 2289 TO -14337 -14592 I/O SELECT' SLOT 7 $C7XX RW RW 51200—53247 -14336 TO -12289 I/O STR SET OBE' INTC8R0M $C800— $CFFF -15616 TO -15361 $C3XX (INTC3) 49920—50175 RESET INTC8R0M RW 53247 LOWER 48 RAM ACCESS RW $CFFF $0000-$BFFF 00000—49151 -65536 TO -16385 HIGH RAM ACCESS RW RW 53248—65535 -12288 TO -00001 $DOOO-$FFFF INT/SLOT ROM ACCESS $C100— $CFFF 49408-53247 -16128 TO -12289 HIGH ROM ACCESS R RW 53248—65535 -12288 TO -00001 $D000— $FFFF does not receive these low order address inputs how the video scanner shares RAM, the RAM directly from the address bus. It receives them from address bus, and the data bus to drive a video map the MMU via the multiplexed RAM address bus as out of RAM for video generator processing. The described in the previous section. other I/O features require more direct manipula- The control functions of various addresses are tion from the MPU. fundamental operational features of the Apple He Apple I/O is memory mapped. This computer computer. For easy reference. Table 2.1 contains a lingo is used to describe a system where the I/O complete list of the address decoded functions of the devices have assigned addresses just like memory. Apple lie. The addresses assigned to I/O in the Apple are in the $CXXX range. This includes the built-in I/Odevices as well as the peripheral slots. I/O (INPUT/OUTPUT) Figure 2.6 is a bus diagram of the Apple He high- The I/O capability of the Apple He is as versatile lighting I/O capabilities. As you would suspect in a as microcomputer bus architecture. We have seen memory mapped I/O system, the address bus is The Bus Structure of the Apple lie 2-1 5 DATA BUS ADDRESS BUS (A0-A1 5) MD0-MD7 ANDR/W ADDRESS BUS ADDRESS BUS EXTENSION DATA BUS DATA BUS EXTENSION Figure 2j6 Bus Diagram: Input/Output In the Apple lie. 2-1 6 Understanding the >^ple He of the I/O the keyboard encoder and processed inside the lOU. directly or indirectly distributed to alldevices are The strobe soft switch is reset when the MPU makes devices. Additionally, most of the I/O a read access to $C010 or a write access to $C01X, connected to the data bus. Hardware control of the I/O devices is via address This provides programmers with a means of detect- , when the MPU addre sses ing akeypress and distinguishing between multiple decoding. In other words must keypresses The program polls $C000 until it finds devic e, circu itry on the moth erbo ard an I/O rate the MSB high (KEYSTROBE). Then it resets detect that address on the address bus and gene KEYSTR$C0 OBE, 00. processes the ASCII, then resumes signals which control that device. polling . , , ,, „ ls will The responseof a device to its control signa If a key is held down continuously for .5 to .8 devic e. Addr essi ng the depend on the nature of the or seconds (32 to 48 television scans), the lOU will start speaker make s the spea ker diap hrag m tense relax Addressi ng the casse tte outpu t cause s the setting the KEYSTROBE soft switch 15times every cassette output line to toggle high or low. Addre ss- second (once every four television scans). To the pro- s the ASCI I of the last key- gram, this looks as if someone is pressing a key 15 ing the keyboard cause press to be placed on the data bus. Addressing a times per second, and the result is the auto-repeat s the card in the slot to do what- feature of the keyboard. peripheral slot cause A second flag related to the keyboard is the AKD ever itwas designed to do when its control signals are activated. (any key dow n) flag, read at $C010. The AKD signal is routed from the keyboard encoder to the lOU and Keyboard Input relayed to MD7 when the lOU detects a read to The Apple He keyboard circuits includex the key- $0010. This gives programmers aNot« little more versa- board, akeyboard encoder IC, and a 2K 8 ROM. tility ininterpreting keypresses. that reading The keyboard and encoder combine to latch ASCII the AKD flag also resets the KEYSTROBE soft switch. for keys that are pressed. The 2K x 8 ROM gives the Apple He a versatile keyboard code translation ca- Peripheral Slots pability and provides a tri-state connection to MDO— MD6 of the data bus. Since the keyboard code The seven peripheral slots are connected to all of is latched, the controlling program can make the the lines of the address bus and, through a bidirec- MPU read the code of th e 1ast key press at any time or tional driver, to all of the lines on the data bus. The any number of times before the following keypress. purpose of the driver is current amplifica- The MPU reads the keyboard input via a read primarytion. In other words, the driver helps motherboard access to $0000. Any read access in the $COOX range data bus signal suppliers in driving peripheral card can be used for this purpose, but the programming signal receivers and vice versa. Timing and control convention is to use $C000. When the MMU detects a signals to thel driver are such that it doesn't isolate read to $COOX on the address bus, it pulls the ena- the periphera slots from data bus signals... with one bling KBD' signal low*. This results in the transfer exception. The driver does prevent video data from of the 7-bit ASCII of the last keypress from the motherboard RAM from reaching the peripheral keyboard ROM to MD0-MD6 of the data bus. slots during MPU write cycles. This seems to have Additionally, the lOU detects the read to $COOX and been done for compatilbility with the Apple II and II places the state of its KEYSTROBE soft switch on Plus. I can see no other reason to deny video data to MD7 of the data bus. The MPU thus reads the state the peripheral slots during write cycles. of KEYSTROBE and the latched ASCII of the last The MMU controls the direction of the peripheral keypress with a single access to $COOX. bidirectional driver via the MD IN/OUT' The KEYSTROBE soft switch is set by the controlbusline. The state of the address bus, R/W, and data KSTRB signal which goes high momentarily any the DMA' and INHIBIT' lines are used to determine time a matrix key is pressed. KSTRB is output by the correct direction for the driver. Direction is in to the data bus when MD IN/OUT' is high and out *KBD' also goes low when a read is made to $C01X although Appledoesnotdocumentthis feature. Daring programmers may from the data bus when MD IN/OUT' is low. exploit this capability to read the keyboard ASCII simultane- I/O SELECT' ($C100-$C7FF), DEVICE ously with AKD or other lOU or MMU flags. Before you write routines like this, please note that AKD becomes valid before SELECT' ($C090-$C0FF), and I/O STROBE' keyboard ASCII as described in Chapter 7. ($C800— $CFFF) signals decoded on the mother- board inform a peripheral card when it is being The Bus Structure of the Apple lie 2-1 7 accessed at one of its assigned addresses. But the byte of data from the data bus. The addresses of the slots are not restricted to response to $C090— input port and output port depend on which slot the $CFFF addressing. The INHIBIT' line allows any disk controller is in. If, as is normally the case, the slot to disable motherboard and auxiliary slot re- disk controller is in Slot 6, the input port address is sponse to$0000— $BFFF and $C100— $FFFF ad- $COEC and the output port address is $C0ED. dressing. With full connection to the address bus Besides $COEC and $CGED, other address com- and data bus, peripheral cards can take advantage mands perform the functions of motor control, drive of this capability in any number of ways. selection, read/write configuration, and head posi- The peripheral slot and auxiliary slot connections tioning. These commands are decoded on the moth- are different from each other in nature. The auxil- erboard and controller. The motherboard circuits iary slot is integrated into the Apple's timing and detect the $COEX range on the address bus and control scheme as an 80-column video card, and activate the Slot 6 DEVICE SELECT' signal to tell connection to the multiplexed RAM address bus, Slot 6 it is being accessed. The controller decodes data bus, and video data bus make the auxiliary slot AO— A3 of the address bus to determine which of 16 ideal for expansion RAM and 80-column cards. possible commands it is being given. Other connections make the auxiliary slot an ideal The actual programming of disk I/O is very com- diagnostic port for production testing or fault isola- plex, requiring timed intervals, data encoding, and tion in malfunctioning motherboards. The periph- extensive software housekeeping. Regardless of this, eral slots, on the other hand, are meant to hold any all MPU control of the disk is via 16 address com- variety of I/O, memory expansion, or system con- mands on the address bus, and all data transfer is trolling device. To this end, the peripheral slots are over the data bus. supported by full connection to the address bus and There is no motherboard ROM routine to load data bus, fixed address assignments, and connection programs from a disk drive when the Apple is first to 6502 control lines and Apple timing signal lines. turned on. A 256-byte program does exist on the controller card, accessible at addresses $0600— Disk I/O $C6FF {assuming Slot 6), which loads the extensive Disk I/O operations are an example of the flexibil- Disk Operating System (DOS) from disk to RAM. ity that the peripheral slots give to the Apple. With After power up, the motherboard firmware turns no peripheral cards plugged in, the Apple He has control over to this controller firmware to get the only an anitiquated cassette interface for loading DOS up and running. and saving memory data. This goes back to the bad DMA and the MPU old days when built-in cassette I/O was a noteworthy convenience. But everybody knows that the primary As Figure 2.6 shows, the MPU address and R/W' means of loading and saving memory data in the lines are connected to the address bus via a 17-bit Apple He is with 5 y^ inch floppy disks. The Apple is tri-state line driver. One purpose for this device is to thought of as a disk based computer, and when a enable the MPU to drive (supply required signal disk controller is installed in a peripheral slot, it is voltages to) all the circuits on the address bus, fully integrated into the Apple, just as if it were a including a possible variety of peripheral cards. A motherboard device. second purpose of the address driver is to give the The data transfer path for disk output is from MPU a tri-state connection to the address bus. This RAM to the MPU to the disk controller to the disk is necessary to isolate the MPU from the address bus drive, and the data input path is the reverse of the during DMA operation, because the 6502 address output path. Data is loaded from the transfer source and R/W outputs are not tri-state. DMA (Direct into the MPU, then stored at the transfer destina- Memory Access) is achieved from a peripheral tion from the MPU. Data transfer between the MPU card when the card pulls the DMA' line low. This and the controller is via the data bus. DMA capability is actually a direct bus access Thedisk controller resides in a peripheral slot and which gives the peripheral card command of the responds to the address bus/data bus environment entire Apple. Pulling the DMA' line low forces the much like RAM. During disk input, the controller 17-bit line driver to high impedance, stops the clock responds to a read access from the MPU by placing a to the MPU, forces the MPU data terminals to input byte of data on the data bus. During disk output, the mode, and affects the MMU read/write control of controller responds to a write access by accepting a the peripheral data bus driver. 2-18 Understanding the Apple lie address decoding. They are direct or indirect out- Unless it is stated otherwise, the discussions in puts of the lOU, with the exception of the C040 UnderKtavdivg the Apple lie assume that no periph- STROBE' which is an output of the peripheral eral card is performing DMA. This means that the address decoding circuitry. The serial outputs and normal situation exists in which the MPU controls their controlling addresses are the data bus during write cycles and always controls the address bus. CONTROL SERIAL OUTPUT The Serial Input Multiplexor ADDRESS Cassette output toggle In addition to the keyboard input and any periph- Speaker toggle eral card inputs to the Apple, there are four paddle IC02X $C03X inputs, three pushbutton inputs, and the cassette ANNUNCIATOR 0 off/on $C04X $C058/$C059 C040 STROBE' input. Each paddle input is tied to a timer which, ANNUNCIATOR 1 off/on when triggered, outputs a high TTL level for a $C05A/$C05B ANNUNCIATOR 2 off/on period of time determined by its paddle .setting. The $C05C/$C05D ANNUNCIATOR 3 off/on four timer pulses, three pushbutton inputs, and the $C05E/$C05F processed cassette input are all applied to the serial A very interesting point about the serial outputs is input multiplexor. that ser iai output data is not transferred on the data When an address in the $00f5X range is on the bus. Most of us would expect a serial output to be address bus. the .serial input multiplexor places one written out on one of the 1 ines of the data bus as if we of its eight inputs on D7 of the [ler ipheral data bus as were writing to memory. But addressing a serial follows: output port merely performs a control function on ADDRESS INPUT the output line. For example, addressing the cassette $C06n/$C068 Cassette input output port toggles the cassette output line, mean- $C061/$C069 Pushbutton 0 ing itchanges the h igh/low state of the output line to $C062/$C06A Pushbutton 1 the opposite state. In other words, the programmer Pushbutton 2 does not write data to the cassette by sending data $C06a/-?C06B $C0fi4/$C06C over the data bus to an output line. Instead, he either Timer (1 $C065/$C06D Timer 1 tells the line to change states or refrains from telling $C066/$C06E Timer 2 the line to change states at a timed interval. $C067/$C0fiF Timer .S Other serial output is similar to the cassette out- put. The output port is addressed, and the control The MMU brings MD IN/OUT' high when a read function— toggle, strobe, level high, or level low— is made in the $C0f5X range. This causes the serial is performed. Speaker, annunciator, and C040 input data to be passed from D7 of the peripheral STROBE' output lines are controlled directly by bus through the bidirectional driver to MD7 of the address decode in a process which ignores the data data bus. The combined response of the serial input bus. The speaker is a toggle output like the cassette multiplexor and the bidirectional driver toa read to output. The programmer can toggle the high/low $C06X allows the MPU to read the serial inputs like state, but he never knows whether the state is high memory. or low. The annunciators are on/off outputs which The serial input mechanization is similar to ROM. can be brought high or low. For example, $0058 A device responds to its address on the address bus makes ANNUNCIATOR 0 go low, and $C059 makes by placing data on the data bus. In this case, how- ever, data is placed on only one line of the data bus. ANNUNCIATOR 0 go high. The 0040 STROBE' simply goes low for half a microsecond any time The MPU receives data from the data bus as it does $C04X ison the address bus, then returns high. when reading data from memory, and the control- Reading or writing to a serial output port is a ling program ignores everything but MD7. The control access as opposed to a data access. The MPU program processes the MD7 information, extracts reads from the data bus or writes to it on every 6502 the transfer data, and stores it in RAM. cycle, even in a control access. The programmer performs a control access with a normal read or The Serial Outputs write instruction, but the data that is read or writ- In addition to the video output and any peripheral ten isirrelevantand ignored. This is why statements card outputs, there are seven serial outputs from the Apple motherboard. These outputs are operated by like "SPEAKER=PEEK(-16336)" are made in BASIC to control the speaker and the data is The Bus Structure of the Apple He 2-19 DATA BUS ADDRESS BUS A0-A15, R/W MD0-WID7 ADDRESS BUS ADDRESS BUS EXTENSION DATA BUS DATA BUS EXTENSION Figure 2.7 The Apple lie Bus Structure. 2-20 Understanding the Apple He is making a control study of this diagram is very important in the effort ignored. The programmer spea ker port), and the to understand the Apple He computer. It is hoped access to -163 36 ($C030. the data is irrelevant. that the reader can become comfortable with the concepts of information flow within the bus struc- ture, because this chapter is the foundation upon which all that follows is built. THE COMPLETED BUS STRUCTURE The remaining chapters are devoted to a more detailed discussion of the various functional areas of The discussion of the bus structure of the Applea He is now complete. This chapter has presented in the Apple lie, beginning with the important subject series of diagrams of the bus structure, building of timing. Understanding these detailed discussions progressed will be much easier if the reader attempts to visual- complexity and completeness asure.we Figur e 2.7 is ize how each area performs its functions within the from basic ideas to detailed struct this series . The autho r feels that bus structure. the final diagram in J",i chapter 3 Timing Generation and the Video Scanner Most operational aspects of the Apple He have technical tools as timing diagrams, truth tables, now been discussed within the context of the bus logic diagrams and schematic diagrams. One of the structure. However, this discussion has left out one goals of Undemtanding the Apple He is to assist of the Apple's most important operational aspects- those readers who desire to do so to analyze the timing. Timing synchronizes everything that goes operationof the Apple lie in depth. For this reason, on in the Apple. To discuss it, we must get into real some technically oriented analysis aids are pre- nuts and bolts detail about computer operation. sented in this chapter and succeeding chapters. Up to this point, the subject matter of Under- These techn ical aids will be accompanied by techni- standing theApple lie has been of a general nature. cal language. Every person reading these words is Noattempt was made in Chapters 1 and 2 to explain capable of understanding the tech n ical sections, but the finer points of Apple lie operation. Having some readers may not wish to. and others will find it gainedunderstandingof the Apple's bus structure, a struggle. Every effort has been made to assist all you are largely aware of the methods of communica- readers in achieving fullest possible understanding tion and control that take place in this computer. from the least possible effort. The following chapters will build on this foundation By way of warning, the details of some functional of understanding, examining and discussing the areas are just plain difficult, but most of the areas detail ed features of al 1 functional areas of the A p pi e are pretty painless.* In particular, much of the He. complexity of the Apple is concentrated in RAM and The perceptive reader is probably getting the its associated circuitry. Some other complicated message that the going is about to become stickier. This book attempts to explain as much as possible *Even thoug-h it is not part of the motherboard circuitry, disk I/O about the operation of the Apple i n understandable is the subject of a chapter of Unili'isfiiiidiuplhi' Apple Ih. Read- English. There comes a point, however, beyond ers intrepid enoiigh to tackle this chapter will find d isk I/O to be a which clear illustration is achieved only with such complex but interestinjr area of study. 3-2 Understanding the Apple He Apple timing originates with a 14.31818 MHz circuitry, like the internal workings of the MPU, crystal oscillator. The output of the oscillator, will not be discussed at all. Besides the RAM circuit- referred to as 14M, isavoltagewhich switches from ry, the most difficult topics probably are the details low to high and back very close to 14,318,180 times of timing and video generation. Timing comes next, every second. The reason for using 14,31818 MHz so put on your overshoes— we're going wading. instead of 14 MHz is that 14,318,180 Hz divided by TIMING OVERVIEW four is 3,579,545 Hz, the exact frequency at which color information is passed in a television set. All of The important timing signals in the Apple He all the distributed timing signals are clocked by low to originate at a small group of circuits called the tim- high transitions of the 14M clock, so the exact fre- ing generator. You should appreciate this when quencies at which events occur in the Apple are studying the Apple, because it makes a difficult job determined by a television signal specification. The easier. Interrelated digital timing originating from approximate frequencies at which some functions multiple sources can scramble your brains. With a occur are: single timing source we can assimilate the timing APPROXIMATE sequences and then apply them to the various func- FUNCTION FREQUENCY tional areas in the following chapters. 6502 Cycle IMHz Timing signals are distributed to all areas of the Video Scanner Increment IMHz Apple, but the Apple's timing requirements are Address Bus Access IMHz determined primarily by RAM usage. RAM is accessed alternately by the 6502 processor and the RAM Access 2 MHz COLOR REFERENCE 3.5 MHz video scanner. Executing a stored sequential pro- 7 MHz max. gram and generating a color televi.sion video signal Video Output are two entirely different tasks, but the two tasks All of these frequencies are determined by outputs are synchronized in the Apple. As we shall see, exe- of the timing generator. cution ofthis double task dictates certai n facts of life The timing generator circuits consist of a 14.31818 about Apple timing. MHz oscillator, a pair of divide-by-two flip-flops, The timing generator controls the timing and and a HAL (Hard Array Logic) IC. The HAL is a affects all areas of the Apple lie. Some of these areas special type of IC whose logic functions can be pro- also affect timing generation (see Figure 3.1). The grammed within the constraints of a format. The external influences areas follows: format of the Apple He timing HAL is a 20-pin IC with eight registered (clocked) outputs driven by 1. One of the timing signals, CAS', is enabled or eight external inputs. This HAL, programmed to disabled by CASEN' from the MMU. 2, VID7 of the video data bus and the display mode Apple's specifications, performs much of the work in generating timing signals for the Apple He, affect the generation of the LDPS' and VID7M video timing signals. THE TIMING SIGNALS 3. An auxiliary card working in coordination with a Slot 1 peripheral card can disable all of the This section is a very brief description of the tim- timing signals and substitute alternate signals. ing signals which are the outputs of the timing gen- This is not normally done in operational Apples, erator. All these signals are described in detail later but it is a capability. in this chapter. 4, Feedback from the video scanner elongates one PHASE 0 is the 1 MHz clock input to the 6502, It system clock period toward the end of each also is used as a general timing reference in the horizontal television scan. MMU and lOU and throughout the motherboard. PHASE 0 defines when an MPU address is valid, The elongation referred to in item 4 above is and whether the MPU or the video scanner is necessary to keep colors consistent from scan to addressing RAM. It is available at the peripheral scan. It also means the clock period of the 6502 is not slots. constant but is elongated on every 65th cycle. This PHASE 1 is PHASE 0 inverted or PHASE 0'. It book will refer to this elongated machine cycle as the long cycle. Because of the feedback from the video is inverted and gated by DMA' to provide the 1 MHz clock input to the 6502. PHASE 1 is used as a timing scanner to the timing generator, the two areas are reference by several motherboard devices and is covered in this single chapter. also available at the peripheral slots. ner Timing Generation and me Video Scan 3-3 c 0 o V > c o O £ E 9 o D c O) o c 3 3 S! Ii^cClIjo ff^i'^'O^ S Sqq>— 1 3-4 Understanding the Apple lie COLOR REFERENCE is a 3.5 MHz clockpulse ERENCE are not affected by this elongation which is used to make up the color burst portion of PHASE 0, PHASE 1, Q3, RAS'. and CAS' are the video output. The color of any Apple video is affected. determined by its phase relationship with the If not for the long cycle, the frequencies of all COLOR REFERENCE signal. COLOR REFER- timing signals could be computed by dividing ENCE isavailable at peripheral Slot 7. 14,318,180 by 14, 7, 4, 2, or l.Inactuality, this works 7M is a 7 MHz clock used only in the generation of for computing the fixed frequencies. 14M occurs at other timing signals. It is also available at the pe- 14.31818 MHz; 7M occurs at 7.15909 MHz; COLOR ripheral slots. REFERENCE occurs at 3.579545 MHz. The 1 MHz 14M is the output of the Apple's 14 MHz clock- and 2 MHz signals are less straightforward. pulse oscillator. It is used in timing generation and The period of time required for a 14.31818 MHz in the shiftingof video patterns in the video genera- signal to go through a complete high/low cycle is tor. As mentioned in the timing overview section, 1/14318180 seconds or about 69,8 nanoseconds (69.8 14M is the ultimatesoureeof Apple timing. billionthsofaseeond). All synchronized durations in HAS' (Row Address Strobe) clocks ROW address the timing generator are multiples of this time information to RAM, and serves as a timing refer- period which we will call the PERIOD for this ence in the lOU and MMU. Among other things, discussion. RAS' defines RAM ROW address time, and RAS' The normal 6502 machine cycle lasts 14 PERI- rising during PHASE 1 causes the video scanner to ODS or about .978 microseconds. The long cycle increment. RAS' occurs twice every 6502 cycle — lasts 16 PERIODS or about 1.12 microseconds. once for MPU access and once for video scanner There are three frequencies involved here; the access. primary frequency at which the 6502 isoperated for CAS' (Column Address Strobe) clocks COLUMN 64 out of 65 cycles, 1.0227 MHz; the secondary fre- address information to motherboard RAM. CAS' is quency at which the 6502 operates for 1 out of 65 gated byCASEN' from the MMU duringPHASEO cycles, .8949 MHz; and the composite frequency toenable or disable motherboard RAM. CAS' always which actually is the number of machine cycles per second, 1.0205 MHz. falls during PHASE 1 and falls during PHASE o'if CASEN'islow. The 2 MHz signals are similar to PHASE Oexcept Q3 is a 2 MHz signal used as a timing reference in that on iy one of every 130 cycles is elongated. Their the MMU and lOU. It is also available at the pe- normal duration is seven PERIODS or about ,489 ripheral slots. microseconds. Their long duration is nine PERI- LDPS' (LoaD Parallel in/Seria! out register) is a ODS or about .629 microseconds. video timing term thatdefines a video cycle. Picture The durations and frequencies ofthe signals of the patterns are loaded while LDPS' is low and shifted timing generator are shown in Tkble 3.1 below. The out to the VIDEO output line when LDPS' is high. values are arithmetic derivations of 14.31818. car- LDPS' occurs once every 6502 cycle in SINGLE- ried to ten place accuracy. Actual frequencies will RES display modes and twice every 6502 cycle in vary as the 14M oscillator varies from 14,318,180 Hz DOUBLE-RES display modes. due to thermal environment and crystal tolerance. VID7M is a video timing signal that enables the Also shown in Table 3,1 are correction factors for 14Mciockpulseof the video shift register. It enables the 50 Hz lOUs and 14.25 MHz oscillators found on shifting every other 14MinTEXT40and HIRES40 Apple lie PAL (Phase Alternating Lines) mother- display modes and shifting every 14M in the other boards. PAL motherboards are designed for coun- display modes. It also may be delayed or undelayed tries using a 50 Hz television scan instead of the in HIRES GRAPHICS mode to control the shifting American 60 Hz scan. Those PAL motherboards of 7-dot groups. with discrete circuit 14M oscillators use a 14.25045 MHz crystal instead of 14.31818, and those with APPLE FREQUENCIES hybrid circuit 14M oscillators operate at 14.25 MHz. The reason for the different frequency is so the 50 It is very hard to make precise statements about Hz Apple He horizontal television scan will approx- the frequencies of some signals in the Apple. This is imate the 50 Hz standard of 64 microseconds. As a because of the clockpulse elongation which occurs side effect, 50 Hz Apple execution speed is slightly every 65th 6502 cycle. 14M, 7M, and COLOR REF- slower than 60 Hz Apple execution speed. Timing Generation and \he Video Scanner 3-5 Table 3.1 Durations and Frequencies of Timing Signals. NORMAL LONG AVERAGE PRIMARY SECONDARY COMPOSITE DURATION DURATION DURATION FREQUENCY FREQUENCY FREQUENCY SIGNAL (nsec) (nsec) (nsec) (MHz) (MHz) (MHz) PHASE 0 977.7779019 1117.460459 979.9268644 1.022727143 .89488625 1.02048432 488.888951 628.5715084 489.9634322 2.045454286 1.590908889 2.04096864 RAS',CAS',Q3 279.3651148 COLOR REF 3.579545 139.6825574 7.15909 7M 14M 69.84127871 14.31818 SCAN NOTES: There are 912 14M periods in a horizontal scan. There are 262 horizontal scans in a 60 Hz vertical scan. There are 312 horizontal scans in a 50 Hz vertical scan. PAL NOTES: Multiply NTSC frequency by ,9952696502 for discrete circuit PAL frequency. Multiply NTSC duration by 1.004752832 for discrete circuit PAL duration. Multiply NTSC frequency by .9952382216 for hybrid circuit PAL frequency. Multiply NTSC duration by 1.004784561 for hybrid circuit PALduration. More information on export Apples is given later signals. The timing diagram is a series of line in this chapter and in Chapter 8. However, much of graphs of voltage as a function of time. Voltage the discussion in this book assumes we are talking changes vertically in the diagram as time passes about American Apples, This is particularly true of from left to right. topics mentioning- frequencies or durations or In thefollowingdiscussionsof timing signals, the details of television scanning and video generation. reader is encouraged to refer to Figure 3.2 as neces- Owners of PALbased Apple He's should read the sary to clarify relationships in his own mind. Time section on export Apples in Chapter 8 to get an good periods will be measured in millionths of a second idea of theareas of difference between 50 Hz and 60 (microseconds) and billionths of a second (nano- seconds). Hz Apple lie's. It is reasonable to wonder why the exact frequen- Figure 3.2 shows three 6502 machine cycles— two cies in the Apple should be of any concern. In fact, normal length cycles and one long cycle. For each for most purposes, the exact frequencies are not normal machine cycle, there is one PHASE 0 cycle, important. They are important when discussing teN two RAS', CAS', and Q3 cycles, three and a half evision compatibility, because television signals COLOR REFERENCE cycles, seven 7M cycles and require some specific frequencies which are not fourteen 14M cycles. For reference, the period of exact multiples of 1 MHz. Frequency is also impor- 14M is about 70 nanoseconds and the period of a tant in so far as it affects MPU execution speeds. normal PHASE 0 cycle is about 978 nanoseconds. Knowledge of 6502 clock speed is very important for The signals illustrated in Figure 3.2 are the tim- Apple programs with precision timing loops. For ing generator outputs, plus AX, HO, and VID7. AX the most part, we will continue to refer to frequen- (Address Multiplex) is a signal which is used only cies in very rough estimates such as 1 MHz or 3,5 inside the timing HAL. It was used in the Apple II to MHz. gate ROW or COLUMN addressing to the multi- plexed RAM address bus. It can be viewed in the THE TIMING DIAGRAM Apple lie at pin 18 of the HAL. HO, the least significant bit of the video scanner, is Timing is usually summarized in timing dia- an output of the lOU and an input to the HAL. Its grams. Figure 3.2 is a timing diagram showing the level alternates approximately when PHASE 0 outputs of the timing generator and some related rises for 64 out of 65 MPU cycles. Every 65th cycle. ■^^.. 3-6 Understanding the Apple lie o c e 5 O) oOk o c 1 o> S! o> x; 5< < 5X ^<: =< =■=t 3< < « CO < < o o o_l i:i => 2 ouj Timing Generation and the Video Scanner 3-7 though, HO stays low for one extra period. It will It is very difficult to illustrate minute propaga- shortly be shown that there are 65 cycles in a horiz- tion delay in a diagram with the time scale of Figure ontal video scan line. The double period with HO low, 3.2. Figure 3.3 more accurately depicts the delay shown in the middle of Figure 3.2, occurs at the hierarchy that exists. The rising edge of 14M is the rightedgeof the Apple display window. master reference of Apple timing, and the basic Look, for a moment, at PHASE 0 at the left sideof features of propagation delay are: Figure 3.2. When PHASE 0 falls for the first time COLOR REFERENCE is high, but when PHASE 0 1. RAS', CAS', Q3, PHASE 0, PHASE 1. LDPS'. VID7M. 7M, and COLOR REFERENCE are falls at the end of the next cycle, COLOR REFER- ENCE islow. This alternating relationship between all clocked by the rising edge of 14M. COLOR PHASE 0 and COLOR REFERENCE is a conse- REFERENCE and 7M are outputs of a 74S109 quence ofthe fact that there are 3.5 eve! es of COLOR with a delay of roughly nine nanoseconds from REFERENCE in one cycle of PHASE 0. The rela^ 14M rising. RAS', CAS', Q3, PHASE 0, PHASE tionship can be defined in terms of HO. COLOR 1, LDPS'. and VID7M are outputs of the 16R8 REFERENCE is low when PHASE 0 falls during HAL with a delay of roughly 14 nanoseconds from 14M rising. HO'. COLOR REFERENCE is high when PHASE 2. PHASE 0 is routed to the6502 through one logic 0 falls during HO. device. Internal 6502 actions cause a further TheHO/PHASEO/COLOR REFERENCE phase relationship is as described above for 64 out of 65 delay before the 6502 data clock (the falling PHASE 0 cycles. It must be this way during video edge of the 6502 PHASE 2 clock). The typical display periods to conform to the overall scheme for 6502 internal delay is not specified in data controlling the colorsintheGRAPHICSmodeof the sheets. The delay between PHASE 0 falling at Apple. The relationship is thrown off, however, by the peripheral slotsand PHASE 2 fallingat the the fact that there are an odd number of PHASE (I 6502 was measured by the author at 28 nanose- cycles (65) in a horizontal scan. If this were not conds.* This delay should varv considerably from 6502 to 6502. corrected for, the relationship would reverse every .S. The video scanner in the lOU is clocked bv the horizontal scan. The correction occursafter the double period with rising between edge of the RAS'rising during delay edgePHASE of I4M l"andThea HO low. The HAL, monitoring HO and the timing change in HO was measured by the author at 80 signals, detects the fact that the relationship has nanoseconds.** In other words, HO changes at changed. It corrects the relationship by delaying approximately the .same time PHASE! 0 rises. generation of the 1 MHz and 2 MHz signals for one This delay should varv considerablv from lOU halfof aCOLOR REFERENCE period. Thedday to lOU. extends the high duration of PH ASE 0 and AX, and itextends the low duration of RAS', C AS\ and Q:i. tt also causes the extension of the current 6502 ma^ TIMING SIGNAL DISTRIBUTION chine cycle (the long cycle). The point at which this delay takes place is shaded in Figure ?,.2. Figure 'AA shows the distribution of timing gen- erator outputs throughout the motherboard. Each With the exception of LDPS' and VID7M, the motherboard device receives the signals it requires timing signals remain fixed in the cyclic patterns to stay synchronized with the overall Apple timing illustrated in Figure 3.2. LDPS' and VID7M will scheme. Note that all timing generator outputs are vary with the Apple display mode and, in HIRES40 connected to pins of the auxiliarv slot, but only mode, with VID7 of the video data bus. The video PHASE 0, PHASE 1, Q3, 7M, nnd COLOR REF- timing shown in Figure 3.2 is for HIRES40 mode, ERENCE are available at the peripheral slots. and VID7M and LDPS' are shown reactingtoVIDT. Peripheral cards must perform their functions with- Chapter 8 contains timing diagrams showing other variations of LDPS' and VID7M. out the benefits of monitoring 14M. RAS' CAS' LDPS'. and VID7M. The signals of Figure 3.2 do not actually rise and fall instantly. It takes them about six nano,secondsto riseandfall. Also, it takes a small amount of time for *S.viiert<'k SyB.W2 (markinE 8807. S10891. 370-fi502) in a Elevi- the outputs of an IC to respond to changes in its siim B Apple He computer. inputs. The delay from input change to output "AM! lOU (markinp 8307 MAA, 344-0030-A) in a Revision B response is referred to as propagation delay. Apple lie computer. 3-8 Understanding the Apple He 6502. As such, its frequency determines the execu- DETAILED DESCRIPTION tion time of instructions in the Apple computer. The OF THE TIMING SIGNALS duration of a PHASE Oor PHASE 1 cycle is equal to the duration of a 6502 cycle. This duration is .98 The following sections describe in detail how the microseconds in a normal cycle and 1.12 microsec- timingsignalsof the Apple He are used. Please refer onds in a long cycle. to Figures 3.2 (timing diagrann) and 3.4 (timing The PHASE 0 cycle period is almost coincident signal distribution) as needed while reading these with a 6502 machine cycle but slightly leads it. discussions. Speaking of PHASE 1 and PHASE 0 as positive gating signals, PHASE 1 occurs approximately PHASE 0 and PHASE 1 during the first half of the 6502 machine cycle and PHASE 0 and PHASE 1 provide the primary 1 PHASE 0 occurs approximately during the second MHz timing reference of the Apple He computer. half. The time relationships of PHASE 1, PHASE 0, They could easily (and more properly) be called IM and the 6502 machi ne cycle are shown in Figure 3.5, and IM' to avoid confusion with the 6502 PHASE 0 Clockpulse action takes place when the 6502 clock input and 6502 PHASE 1 internal clock. As PHASE 0 clockpulse input line switches from high the names IM and IM' imply, PHASE 1 is simply to low or low to high. These transitions trigger the exact inversion of PHASE 0. PHASE 1 is high actions inside the 6502 which will be discussed in when PHASE 0 is low and vice versa. greater detail in the next chapter. A high to low transition of PHASE 0 causes the 6502 to begin a PHASE 1 is inverted and gated by DMA' high to become the 1 MHz PHASE Oclockpulse input to the new machine cycle after a short delay. Time in Nanoseconds 7M COLOR REF 14 HAS' CAS' 03 PHASE 1 PHASED LOPS' VID7M 42 6502 PHASE 2 30 HO Figure 3^ Propagation Delay Hierarchy. Timing Generation and the Video Scanner 3-9 ADDRESS "X> DATA BUS BUS r ^ <1>0 R/W 03 •\>0 *! -<]- J_LL PERIPHERAL SLOTS DMA' TT 7M COLOR REF (SLOT 7 ONLY) IN 4>0 SERIAL KYBRD PERIPH CODE CUITS MUX DE- OE' 1± -^dSzl RAS' to Q3 RAS' CAS' ■14M CIR- 1 R/W MIVIU RAM MAIN . VID7M LATCH VIDEO RAS- Q3 .I'l . COLOR GEN, RAS' 4.0 Q3 J_L ._ AUX REF . LDPS' J LATCH lOU RAM I 14M 7M REF CAS' LDPS' VID7M COLOR FIgui* 34 Distrrbutlon of Timing Generator Outputs. 3-10 Understanding the Apple He PHASE 1 / 1 / PHASED V / V 6502 MACHINE CYCLE Figure 35 The 6502 Mach ine Cycle Slightly Lags the PHASE 0 Clockpulse. In addition to triprperinfc 6502 events, PHASE 0 7M is available at pin 36 of the peripheral slots. and PEIASE 1 are used as a lime reference on the COLOR REFERENCE isavailableatpin35of Slot nnotherboard. During PHASE 0, the 6502 address is 7 only. 14M is not available at the peripheral slots. valid so address decfKlinp from the address bus takes place durinsj PHASE 0. RAM is addressed by RAS',CAS',andQ3 the MPU during PHASE 0, and by the video RAS', CAS', and Q3 are 2 MHz signals. Q3 is used scanner during- PHASE 1. Videodata from RAM is as a timing reference in the MMU and lOU, and is latched at PHASE 0 rising, and the video data bus available at the peripheral slots. It is named Q3 contains latched RAM data from the auxiliary card because it is identical to the Q3 signal (the Q3 output durintr PHASE 0, and from the motherboard dur- of a 74S195)of the Apple II. Q3 is also used to strobe ing PHASF) 1. Also, since scanner access is during the COLUMN address to auxiliary card RAM. PHASE 1, the RAM read/write control is set to RAS' and CAS' are RAM timing signals that "read" during PHASE 1, even if the 6502 R/W line strobe the ROW and COLUMN addresses to mother- is set to "write." board RAM. It can be seen from Figure 3.2 that a 14M, 7M, and COLOR REFERENCE RAS'/CA S' sequence occurs twice every 6502 cycle. The PHASE 1 sequence controls the video scanner I4M and COLOR REFERENCE (3.5M) are util- access to RAM, and the PHASE 0 sequence controls ity clocks which are u.sed in the generation of video. the MPU access to RAM. The falling edges of RAS' The frequency of Apple video can be as high as 7 and CAS' strobe the ROW address and COLUMN MHk, so generating the video signal requires fast address to RAM. while RAS' selects ROW or COL- clocks. 7M is a utility clock available at the periph- UMN address lines at the multiplexed address out- eral slots, but not used on the motherboard except in puts of the lOU and MMU. There is a continuing the timing HAL. cycle of RAM access: 14M, 7M, and COLOR REFERENCE are unaf- fected bythe long cycle and have fixed frequencies 1. Select ROW address via RAS' high. of 14.318180 MHz, 7,15909 MHz and 3.579545 MHz 2. Strobe ROW address via RAS' falling. respectively. 14M is used strictly as a clockpulse in 3. Select COLUMN address via RAS' low. the video generator, but COLOR REFERENCE is 4. Strobe COLUMN address via CAS' falling. used differently. Short bursts of the COLOR REF- ERENCE signal are placed on the videooutput line RAS' is wired directly to all of the motherboard and auxiliary card RAM chips, and to the lOU and once every horizontal scan. A television set is capa- ble of reproducing the continuous COLOR REF- ERENCE signal from these short bursts, allowing *This book refers to the signal which controls the intensity of the theCOLORREFERENCEinputto the television to Apple display as the PICTURE signal. When the PICTURE become the phase reference for color generation. signal is at the white level, the electron beam in the television The Apple produces color on a television by shifting picture tube strikes the picture screen with enough intensiG' to the PICTURE signal in relation to the COLOR cause lightemission. The PICTURE signal SYNC, and COLOR BURST are the three components of the Apple VIDEO signal. REFERENCE.* More information on this subject is contained in Chapter 8. Timing Generation and the Video Scanner 3-1 1 MMU as well. It serves as a general timing refer- Figure 3.6. Remember that in all instances, the ence inthe lOU and MMU, and RAS' rising during events will occur substantially later than their gat- PHASE 1 is the clockpulse which increments the ing inputs because of the long propagation delays in video scanner. the MMU and lOU. CAS' is connected directly to the eight mother- board RAM chips. It always falls once during LDPS'andVID7M PHASE 1, but it only falls during PHASE 0 if LDPS' and VID7M are timing signals used in the CASEN' from the MMU is low. When the MPU generation of video. These signals vary considerably is accessing motherboard RAM, the MMU holds with the Apple display mode, and they are discussed CASEN' low, enabling CAS' during PHASE 0 and in greater detail in Chapter 8 than they are here. subsequent data transfer between motherboard The generation of the PICTURE signal is a load/ RAM and the data bus. When the MPU is accessing shift process. Text or graphics patterns are loaded any device other than motherboard RAM, the MMU from a ROM which is addressed by latched RAM holds CASEN' high, d isabling CAS' during PHASE data. The patterns are then shifted out as the PIC- 0, and isolating motherboard RAM from the data TURE signal. LDPS' is the load/shift reference for bus. PICTURE signal generation. While LDPS' is low, CAS' is not used as the COLUMN address strobe patterns are loaded in the video generator. While or the RAM enabling signal on the auxiliary card LDPS' is high, they are shifted out. LDPS' always RAM. Q3 is the auxiliary card COLUMN address drops low near the end of PHASE L In DOUBLE- strobe, and communication between the data bus RES ofvideo end PHASEmodes, 0. LDPS' also drops low near the and auxiliary card RAM is enabled or disabled at the auxiliary RAM card bidirectional data bus VID7M is the clockpulse enable signal for the driver. The enable/disable signal for this function is PICTURE signal load/shift register. When VID7M EN80' from the MMU. is low, 14M risingcauses the register to load or shift. The three signals which provide the timing refer- In TEXT40 and HIRES40 display modes, VID7M is ence inthe the custom ICs are PHASE 0, RAS', and a 7 MHz signal {thus the name VID7M). This 7 MHz Q3. The relationships of these signals and some signal enables loading or shifting every other 14M major events that they control are illustrated in rising, and is usual ly identical to the 7M clock, but in Increment Latch MPU row video scanner address in lOU r n PHASED J \ RAS' 03 / ^ I / VIDEO VIDEO MPU MPU VIDEO ROW COLUMN ROW COLUMN ROW Figure 3;6 Timing DIagiam: MMU and lOU Signals. 3-1 2 Understanding the Apple lie HIRES40 delayed video cycles, VID7M is the inver- television, but the signal input synchronizes the sion of the 7M clock. scanning with horizontal and vertical sync. The In the LORES40 and DOUBLE-RES display horizontal sync causes the beam to return very modes, VID7M is a constant low. This enables pat- quickly to the left side of the screen, and the vertical tern loading or shifting- every time 14M rises, so sync causes the beam to return very quickly to the patterns are shifted out twice as fast as in TEXT40 top of the screen. The horizontal and vertical sync and HIRES40 display modes. must occur approximately and vertical frequencies for at' the television television horizontal to become TELEVISION SCANNING synced. In American television, the horizontal scan- ning frequency is 15,734 Hz and the vertical scan- To understand the operation of the video scanner, ning frequency is 59.94 Hz. it is necessary to understand a little bit about televi- Horizontal and vertical sync occur while the PIC- sion operation.* The television display is achieved TURE signal is at a b lack , or blanking, level . After by scann ing an electron beam across the screen . The the horizontal sync causes the beam to go to the left PICTURE signal level controls the beam intensity side, the beam traces left to right while the PIC- and the resulting light intensity as the viewer sees it. TURE signal controls beam intensity. The electron beam scans much faster horizontally The Apple must generate the television signal than it does vertically, so the scan or raster is made which is a combination of horizontal sync, vertical up of many nearly horizontal lines as shown in Fig- sync, picture level, and a color burst. It does this by ure 3.7, The scanning circuitry is internal to the scanning memory for video output with a counter which has recurring periods approximately equal to *Chapter 8 contains a more detailed description of television operatiim. The important concepts here are television scanning the horizontal and vertical periods of a television. and synchronization. This counter is the video scanner. Figure 3.7 Exaggerated View of a Television Scan. Tinning Generation and the Video Scanner 3-13 THE VIDEO SCANNER the 65-state sequence represents one horizontal The video scanner is a counter inside the JOU that scan. During 40 of the states, picture information is counts like a television scans (see Figure 3.8). The output on the video line. During the remaining 25 states, the picture is blanked. The blanking period low order bits (HPE'-H5-H4-H3-H2-H1-H0) form includes the left margin, right margin, and retrace the horizontal section which sequences through its counts once for every horizontal scan. The hiph (quick movement of the beam from right to left). The duration of the horizontal sequence is equal to order bits T 15H2 .AUTOSTRB (TO 7.1) .66.8fns- (15Hz) CLR OR POWER-UP RESET (33 msec) Veilical section m 262 overflow onio [iiBsels VERTICAL 011111010 1011001000 STATES t5 TOlOU hiiopOiinl 50 (312Hz) CLEAR VIDEO IF SCANNER SWITCHES AT SOFT POWER UP (7-1) ■HO VO-VSl '> 65 HORIZONTAL VA-VC^ TO Huiizoiilal secttor piesBislo lOOOOOO STATES whenHPE is low 40 H(>H5J 3.9) (3 91 --^ - Video scanner increments when (3 91 ^- RAS rises during PHASE 1 (3.91 -'- 8.5 ^ 01 m lOOKMO. Smrmn^ "^'^ ,"'^ in resulting ^«'""' ^^^''0" states 312 vertical Presets to Figure 3.8 Functional Diagram: The Video Scanner. Timing Generation and \he Video Scanner 3-15 Table 32 Video Scanner States (1 o( 2). HDRIZOnSVL scmswG AMERICAN VEETTCAL SCfiNNING RffitSPEflN VERTICAL SCAbWIHG CK VERTICAL DISPLAY VERTICAL DISPUQf VEOTICAL HDR. HDR. VEKl'lCAL SBCTICW saancN NO EVENT SBCriClN LINE MQ EVENTS LINE hO mofps P 543 lUi 543 210 CBA 543 210 CBA 1 001 100 53 BURST 1 001 101 54 KJRST 011 010 IXX 268-271 55 HJRST 011 011 0XX 272-275 1 001 110 1 001 111 56 HJRST 111 100 IXX 228-231 011 011 IXX 276-279 TEStT 1 0US 00Bi 57 111 101 0XX 232-235 011 100 0XX 280-283 i 1 SLfB 001 58 111 101 IXX 236-239 011 100 IXX 284-287 1 010 010 111 110 0BQC 240-243 011 101 0XX 288-291 59 1 010 011 111 110 IXX 244-247 011 101 IXX 292-295 1 010 100 61 60 111 111 0iXX 248-251 011 110 0XX 296-299 1 010 101 111 111 IXX 252-255 PRESET 011 110 IXX 300-303 1 010 110 63 62 011 111 01X 256-257 011 111 0XX 304-307 1 010 111 64 011 111 IXX 258-261 011 111 IXX 3^-311 VBL', GR 1 \ VBL', GR 000-003 1 011 000 00 100 000 0XX 000-003 100 000 0XX 1 011 001 1 011 010 01 02 ( 100 100 0t)0 IXX 001 0XX 004-007 008-011 i t 100 100 000 001 IXX 0XX 004-007 008-011 1 011 011 03 HBL' 100 001 IXX 012-015 100 001 IXX 012-015 1 011 100 04 100 010 0XX 016-019 016-019 100 010 0XX 1 011 101 05 100 010 IXX 020-023 100 010 LXX 020-023 1 011 110 06 100 011 0XX 100 011 0XX 024-027 024-027 1 011 111 100 011 LXX 028-031 100 011 IXX 028-031 07 1 100 000 08 100 100 0XX 032-035 100 100 0XX 032-035 1 100 001 09 100 100 IXX 036-039 100 100 IXX 036-039 1 100 010 10 100 101 0XX U4W-04J 100 101 0XX 040-043 1 100 011 11 100 101 DOC 044-047 100 101 IXX 044-047 12 1 100 100 100 110 0XX 048-051 100 110 0XX 048-051 1 L00 101 13 100 110 IXX 100 110 IXX 052-055 052-055 1 100 110 14 15 100 111 0XX 056-059 100 111 0XX 056-059 1 100 111 100 111 LXX 100 111 IXX 060-063 060-063 1 101 000 16 101 000 0XX 064-067 101 000 0XX 1 101 001 064-067 101 000 IXX 101 000 IXX 068-071 17 068-071 1 101 010 18 101 001 0XX 101 001 OXX 072-075 19 072-075 1 101 011 101 001 IXX 076-079 101 001 IXX 076-079 1 101 100 20 101 010 0XX 080-083 101 010 0XX 080-083 1 101 101 21 101 010 LXX 101 010 IXX 084-087 084-087 1 101 110 22 101 011 0XX 101 011 0XX 088-091 088-091 1 101 111 23 ■01 011 IXX 101 011 IXX 092-095 24 092-095 1 110 000 L01 100 0XX 101 100 0XX 096-099 096-099 1 110 001 25 L01 100 IXX 100-103 101 100 IXX 100-103 26 104-107 1 110 010 101 101 0XX 101 101 0XX 104-107 108-111 1 110 011 27 101 101 IXX 108-111 101 101 IXX 1 110 100 28 29 101 110 0XX 112-115 101 110 0XX 112-115 1 110 101 101 110 IXX 116-119 101 110 IXX 116-119 1 110 110 30 101 111 0XX 120-123 101 ill 0XX 120-123 1 110 111 31 101 111 LXX 124-127 101 111 IXX 124-127 3-16 Understanding the Apple He Table 32 Video Scanner States (2 of 2). EUROPEAN VERTICAL SGRMUNS HDRIZONIW. scBume AMfcKECflN VERTICAL SCAMJING VERTICAL DlSPIAy CK ::al EVENTS HDR. HDR. VtMi'ICAL DISPLAY EVENTS 1 VtSiTlCAL LINE H3 SBCTICN MO EVQff SBCnCM LINE MO SECTICM P 543 210 543 210 CBA VKKl-K 543 210 CBA 1 ill 000 110 000 0XX 128-131 U0 000 0XX 128-131 32 132-135 1 111 001 33 110 000 IXX 132-135 110 000 IXX 34 136-139 110 001 0XX 136-139 1 Ul 010 110 001 0XX 1 111 011 110 001 iXX. 110 001 IXX 140-143 35 140-143 110 010 0XX 144-147 1 ill 100 36 110 010 0yx 144-147 1 ill 101 110 010 IXX 148-151 110 010 IXX 148-151 1 Ul 110 38 37 110 011 0XX 152-155 110 011 0XX 152-155 1 lii Ul 39 VERT+l 110 011 IXX 156-159 110 011 IXX 156-159 TEXT 160-163 TEXT 0 000 000 40 1 ' 160-163 110 100 0XX 41 HBL 110 110 100 0'XX IXX 110 100 IXX 164-167 1 000 000 164-167 \ 1 000 001 42 110 101 0XX 110 101 0XX 168-171 168-171 172-175 1 000 010 43 110 101 IXX 172-175 110 101 IXX 1 000 011 110 110 0XX 110 110 0XX 176-179 44 176-179 1 000 100 45 110 110 IXX 180-183 110 110 IXX 180-183 1 000 101 46 110 Ul 0XX 184-187 110 Ul 0XX 184-187 1 000 110 47 110 Ul IXX 188-191 '■ 110 Ul IXX 188-191 VHL, GR I VBL, GR 48 192-195 i 1 1 000 111 111 000 0XX Ul 000 0KX 192-195 1 001 000 49 SMnFC 111 000 IXX 111 000 IXX 196-199 196-199 1 001 001 SiNC 111 001 0XX 200-203 Ul 001 0XX 200-203 \ \ 50 111 001 IXX 1 001 010 51 SYNC 111 001 IXX 204-207 204-207 1 001 011 52 SYNC 111 010 EKX 208-211 111 010 0XX 208-211 111 010 IXX 212-215 lU 010 IXX 212-215 111 011 0XX Ul 011 0XX 216-219 216-219 111 011 IXX 220-223 Ul 011 IXX 220-223 111 100 0XX SYNCjTJ IT 111 100 0XX 224-227 i1 224-227 Ul 100 IXX 228-231 lEXT '' Ul 101 0XX 232-235 Ul 101 IXX 236-239 111 110 0XX 240-243 111 110 IXX 244-247 Ul Ul 0XX 248-251 111 111 IXX 252-255 PRESET 011 001 0XX 256-259 GR 011 011 001 010 iXX 0XX 260-263 264-267 1 SYNC NOTK; Shml t'k'visi(m vertical Konta!fro(iiiency isafi^tin-iesthe vertical frequency. fretiiieiicy u{ h^.).m FIz. In American broadcast television, the horizontal In a standmvl television jiiL-ture. aRcrnatinK ver- frequency is 2f>2„5 times the vertical frequency. tical scans are interlaced. This means that every other downward scan is displaced vertically half of Export Apples and the Video Scanner thedistance between two hori/.onta,! scans. Inlerlac- The television systems of many countries, includ- iriKKives an effective vertical resolution of r>25 lines. inj^ those of F^virope, have SO Hz scanning: rates There is no verlica! interlace in the Apple display. instead of the 6() Hz rate of America. The Apple He This accounts for a disparity in vertieal/horijLontal can be madetosui>portr)() H/, television scanning by freipicncy relationships between Apple video and installing: a 14.25 MHz crystal and a 50 Hz lOU. Timing Generation and the Video Scanner 3-1 7 The lower frequency crystal changes the period of a at frequencies that suggest they are controlled by a horizontal scan from about 63.7 microseconds to simple binary counter incrementing, or perhaps about 64 microseconds. The 50 Hz lOU adds 50 decrementing, when the video scanner overflows. horizontal scans to the vertical scan to yield a verti- Another circuit not mentioned in Apple literature cal rate of about 50 Hz. is the power-up reset circuit. When the Apple He is The 50 Hz lOU and 14.25 MHz crystals are first turned on, the lOU holds the RESET' line low installed in special motherboards that have PAL for about 33 milliseconds. If you prevent the video (Phase Alternating Lines) color encoding circuitry scanner from counting by pulling CLKEN' high, built-in. PAL is a 50 Hz television system used in the RESET' line stays low until you enable the 14M many countries including all major western Euro- clock and let the scanner count for a while. When the pean countries except France. Asof thiswriting, the RESET' line does go high, it does so approximately 14M oscillator is made of discrete circuits and the when the video scanner overflows, as closely as I can crystal used is 14.25045 MHz (see Figure 3.9). How- observe. My deduction is that the video scanner ever, Apple has developed a hybrid oscillator which presets to 000000000/0000000 at power-up, and that is used in the Apple He and will probably see use in the RESET' line is allowed to rise 32.6 milliseconds the Apple He. The frequency i n the export version of later when the scanner overflows for the first time. the hybrid oscillator is 14.25 MHz. Both of these The Figure 3.8 power-up reset circuit will generate frequencies yield approximate horizontal scan dura- tions of64 microseconds (63.998 from 14.25045 and such a reset.* Figure 3.8 shows generation of an AUTOSTRB 64.000 from 14.25). signal which is an artificial keyboard strobe. The In the 50 Hz lOU, the vertical section of the video KE YSTROBE soft switch is set when either KSTRB scanner presets on overflow to 011001000 instead of (the real keyboard strobe) or AUTOSTROBE goes 011111010. There are 312 states represented by high. When a key is held for 534—801 milliseconds, 011001000-111111111. This gives a vertical fre- the AUTOSTRB starts to alternate at 15 Hz, re- quency of50.08 Hz. Even though there are 50 extra peatedly settingtheKEYSTROBEsoftswiteh{Fig- horizontal scans in the 50 Hz Apple, there is noextra ure 7.1)to simulate rapid keypresses. vertical resolution. In either scanning system, there F3 of the flash counter is the clockpulse for gener- are 192 horizontal scans in which picture informa- ating the delay before auto repeat. This can be tion isdisplayed. deduced from the 267-millisecond variation in the The Flash Counter and delay. The delay could be produced from a 2-bit counter or from a 3-bit shift register like the one Power-up Reset Circuit shown in Figure 3.8. In either case, KSTRB must reset the delay generator so that pressing a key FO— F4 of Figure 3.8 make up the flash counter. This counter counts television scans, and I call it the interrupts the auto repeat function until the delay times out again. flash counter because F4 is used to switch flashing text between NOEMALand INVERSE. Flashing The variation in duration of the delay before auto repeat is a mild problem for me. This delay should text doesn't necessarily have to be in sync with the be nearly constant if a typist is to become skillful at display scan, but the video scanner provides a handy uninterrupted recurring signal (the scanner over- performing keyboard auto repeat functions. I feel flow) which the lOU uses for a time reference. Other that a variation of .267 seconds here is too great, and functions which depend on the flash counter for a that it prevents me from really making the key- time reference are the delay before activating the board "sing." The variation could be reduced greatly keyboard auto repeat function, the frequency of the if the 3-bit shift register in Figure 3.8 were replaced keyboard auto repeat function, and the time-out by a 4-bit VPE counter, identical to the first four period of the power-up reset. bits of the flash counter except that it is cleared The flash counter is not mentioned in any pub- when KSTRB is high or AKD is low. The overflow lished Apple literature that I know of. The Figure from this counter would be an auto repeat enable 3.8representation and the "flash counter" and "FO— signal, delayed from the initial keypress by 534— 551 milliseconds. F4" nomenclature are mine, not Apple's. The reason for my assumption of the existence of the flash counter is that the flashing text, power-up reset, and •The power-up reset duration can only be measured with no Di8l< auto repeat functions always toggle just after a II controller in any peripheral slot, because the controller 100 video scanner overflow. Also, these features operate msec power-up reset will mask the FOU 33 msec power-up reset. 3-18 Understanding the Apple lie -H RAS' ) JO AUX SLOT iry >{ VID7M ) < CAS' ) {7.8) 55 FRCTXr 10.4^^5, ^ -• 17 -» \A GR*2 h: LDfS' ) E5 LS10 lOU HO 40 SEGB (8.5) 80C0L' NOTES. T GND C91 C90 C92 -220 4^220 lb220 rji Connections provided for alternale oscillator, J^pF J^pF J^pF EOn Revision A motherboards, E5-2 is connected Oirectly to D1-7 Ttie addition of FRCTXr gating in Revision B makes the OOUBLE-RES graphics modes possible. Figure 3.9 Schematic: The Timing Generator. Timing Generation and the Video Scanner 3-19 The durations of events controlled by the flash TIMING GENERATOR HARDWARE counter are generally exact multiples of the dura- tion ofa vertical scan. The exception is the power-up Timing generation in the Apple consists of mak- reset time out which lasts 512 horizontal scans (the ing alot out of a little. By this I mean that the 14M clear-to-overflow period of the verti cal section of the clock is divided and processed to make the slower, video scanner). Durations and frequencies of events more complex signals. Most of the processing is per- controlled by the flash counter are listed in Ikble formed inthe timing HAL. 3.3. With the exception of the power-up reset, dura- I4M comes from a crystal controlled 14.31818 tions will be about 1.2 times longer in 50 Hz lOUs. MHz oscillator via one fourth of a 74LS125 tri-state driver (see Figure 3.9). 14M is pretty symmetrical, THE LONG CYCLE but symmetry is not important since only the rising edge of 14M is used in the Apple. The discussions have alluded to the long cycle in a The tri-state 14M driver is always enabled unless limited way, but we are now in a better position to the Apple has a special peripheral card installed in understand the reasons for it. Slot 1. It is possible for a Slot 1 card to isolate the Video output begins each horizontal scan when 14M line from the motherboard oscillator by bring- the horizontal count reaches 1011000. For color ing CLKEN' high. An auxiliary card can then sub- coherency, the video output needs to begin at the stitute itsown master clock signal for the disabled same point in relation to COLOR REFERENCE on motherboard 14M signal. With peripheral Slot 1 every scan. Since there are 3.5 COLOR REFER- emptyora peripheral card with pin 19open installed ENCE cycles in a video scanner cycle, the phase of in Slot 1, the CLKEN' line is open and pull-down COLOR REFERENCE at the start of a video shift resistor R28 keeps the 14M tri-state driver enabled. alternates 180 degrees each scanner cycle. Because The CLKEN' feature could be used by diagnostic of the 180 degree phase alternation each cycle, a cards designed to check out and troubleshoot Apples. 7-dot HIRES40 pattern represents different colors It could also be used in some mad hacker scheme too when it is stored in an even RAM add ress than when insane for me to envision. If a mad hacker happens it is stored in an odd RAM address. to read this, my advice, if you want to change the There are 65 video scanner cycles per horizontal 14M frequency, is to ignore the CLKEN' line and screen line. Since this is an odd number, there would change the crystal. be an odd number of 180 degree phase alternations 7M and COLOR REFERENCE generation is per horizontal line. This would cause the starting straightforward frequency division. 7M is 14M phase relationship to alternate every horizontal line. divided by two. COLOR REFERENCE is 7M di- By delaying video shift timing half of a COLOR vided bytwo. The connections are such that COLOR REFERENCE period once every horizontal line, REFERENCE toggles when 7M falls (see Figure the same beginning phase relationship occurs every 3.2). The frequency division takes place in a 74S109 horizontal line. As a side effect, all 1 MHz and 2 dual flip-flop. An S109 is used here instead of an MHz signals are elongated once every horizontal line. LS109 because the S109 has more driving power, and 7M is distributed to all of the peripheral slots. Table 3.3 Events Controlled by the Flash Counter. DURATION/ EVENT FREQUENCY REMARKS Power-up reset 32.6 msec 512 horizontal scans Flash cycle 1.87 Hz Vertical freq./32 Delay before auto repeat 534—801 msec 32-48 vertical scans Auto repeat frequency 15 Hz Vertical freq./4 "^^^^ 3-20 Understanding the Apple tie Figure 3.10 is certain to be different than the 14M, 7M, and COLOR REFERENCE are inputs actual Apple HAL in minor details. There is little to the HAL. This single IC generates all of the room for variation, however, in the substance of the remaining tinning signals— PHASE 0, PHASE 1, resulting logic equations. It was not at all obvious to RAS', CAS', Q3, LDPS', and VID7M. me how some of the required logic functions could b« The Timing HAL performed with the available inputs. I was only able to come up with a working layout after considerable HAL (Hard Array Logic) and PAL (Programma- ble Array Logic) are a relatively recent develop- head scratching. Apple's effort in visualizing the ment in microelectronics. They are skeletal logic timing generator as a HAL application and in pro- ducing such an efficient design is impressive. structures whose actual logic functions can be speci- fied ,in the case of HAL, or programmed, in the case 'Ikble3.4 is a list of logic equations reduced from of PAL. Figure 3.10. Most readers will find these equations The Monolithic Memories series of HALand PAL easier to analyze. Both T^ble 3.4 and Figure 3.10 are isavailabie in a variety of skeletal structures having presented here for reference, however, and com- STTL signal I/O characteristics. An engineer can plete analysis will not be particularly valuable for choose a HAL/PAL, then design and debug his most readers. A good grasp of the Figure 3.2 timing application using field programmable PALs. If diagram is much more important in understanding there is enough volume to merit it, the debugged IC the Apple. For those who are interested in the HAL can then be ordered directly from the manufacturer layout, here are some interesting features. as HAL. In the case of the Apple lie, there is, of course, enough volume to merit purchase of HAL 1. All outputs are the inversion of the flip-flop out- from the manufacturer. puts, so setting a flip-flop causes its output line The HAL used in the Apple He is a HAL16R8 to go low and vice versa. which contains eight D flip-flops fed by multiple 2. The RAS'. AX, CAS', Q3, PHASE 0, and PHASE 1 logic is best thought of as set/hold and/or input logic arrays. The flip-flops are all logic. The set terms do not have feedback from clocked by 14M rising, so the HAL outputs all expe- rience approximately the same propagation delay the flip-flop they are controlling, but the hold from 14M rising (about 14 nanoseconds). The 16R8 terms only come true if the flip-flop they are outputs are tri-state, and the outputs are disabled if controlling is already set. The flip-flop sets if any set term comes true, and a flip-flop, once set, an auxiliary card brings the pulled down ENTMG' will stay set if any set term or hold term is true. line high. All timing generator signals are con- nected tothe auxiliary slot so an auxiliary card can 3. RAS', AX, CAS', and Q3 are set up as a shift substitute its own signals for the PAL outputs. The register. If Q3 is high, a low level is shifted to RAS' then AX then CAS' then Q3 (with special ENTMG' that I knowline of. is open on every auxiliary slot card logic on Q3 since CAS' won't fall during PHASE Figure 3.10 is a 16R8, programmed to operate as 0 if C ASEN' is high). If Q3 is low, a high level is shifted CAS' and to AXQ3. then RAS' then simultaneously to the Apple lie timing HAL. I filled in the X's to match the timing signal characteristics of the Revi- sion B Apple He. The Revision A HAL must be 4. The delay logic that causes the long cycle is the different than the Revision B HAL, because GR+2 is H2 and H3 terms of the RAS' flip-flop. distributed to the Rev A HAL and gated GR+2' is 5. C ASEN' from the MMU is not PHASE 0 gated, distributed to the Rev B HAL. The GR/GR' X's must so the CAS' flip-flop must set during PHASE 1 therefore be swapped in the Rev A HAL layout as whether CASEN' is high or low (see the S2 term opposed to the Rev B HAL layout.* on the CAS' flip-flop). 6. The SEGB, gated GR+2', VID7, and 80COL' inputs to the PAL are used only in generation of *A second difference with the Rev A HAL is that the COLOR REFERENCE has a different phase relationship with the other LDPS' and VID7M. Also, none of the other HAL signals than that illustrated in Figure 3.2. The Rev A PAL would outputs are affected by LDPS' and VID7M. thus result in non-standard colors if plugged into a Rev B LDPS' and VID7M generation is discussed in motherboard. Chapter 8. Timing Generation and the Video Scanner 3-21 i6Re 14M — > 7MH:S AX (NO COLOR ^J>F REF ^^ RAS' HO H^ Q3 (J^O V1D7 H> CAS' SEGB H^ *1 GATED HVz^ GR^2' ^^^ VID7M CASEN' H> 80C0L' ^-\^ ] i •, t I I vigil i^ijiii; t«irriis JOJir^n nmkU :if NOTE: Inc, drawXs Ing Base Tfie is from "B ipolar LS1 1984 Databook," fifth edition, reprinted with permission from Monolittiic IVIemories, were filled in by Jim Sather. ENTLMDGP'S' Figure 3.1 0 The Timing HAL Layout. 3-22 Underetanding the Apple He Table 34 Timing HAL Logic Equations. PIN ASSIGNMENTS ARRAY INPUTS OUTPUTS OTHER INPUTS 10-2 = 7M Q0'-19 = RAS' CP-1 = 14M 11-3 = CLR REF Ql'48-AX OE'-ll - ENTMG' 12-4 = HO Q2'- 17 = CAS' VCC-20 = +5V I3-5-VID7 Q3'-16 = Q3' GND-10 = GROUND 14-6 = SEGB Q4'-15 = *0 15-7 = GATED GR+2' Q5'-14 = *l I6-8 = CASEN' Q6'-13 = VID7M 17-9 = 80COL' Q7'-12 = LDPS' SIGNAL NOTES EQUATIONS S1=Q3 FALL AFTER Q3 RISES RISE AFTER AX RISES RAS' H1=RAS".AX' H2=RAS".CLRREF.H0.*0 LONG CYCLE DELAY H3- RAS" • 7M' • HO • *0 LONG CYCLE DELAY AX S1 = RAS"»Q3 FALL AFTER RAS' FALLS H1=AX'.Q3 RISE AFTER Q3 FALLS 51 = AX'»CASEN" MMU, MAY I? NUTS TO MMU DURING *1 CAS' 52 = AX'.*1 H1=CAS".RAS" RISE AFTER RAS' RISES 51 = AX'.0 . Q3 VID7M S1=GR".SEGB LORES GRAPHICS IS HIGH SPEED 52 = GR' . 80COL" DOUBLE RES IS HIGH SPEED 53 = GR'«7M SAME AS 7M IF NOT HIRES 54 = VID7'»*1»Q3'.AX' HIRES DELAY CHECK DISPLAY AT *1 • Q3' • AX' 55 = HO' . CLR REF • t>l • Q3' • AX' NO DELAY AT RIGHT EDGE T1 = VID7M.AX TOGGLE THROUGH AX T2 = VID7M . *0 KEEP TOGGLING THROUGH $0 T3 = VID7M • Q3 KEEP TOGGLING THROUGH Q3 51 = Q3' • AX' . 80COL" • GR' DOUBLEMODE RES CAUSES DOUBLE LDPS' LDPS' TEXT 52 = Q3' • AX' • *1 . GR' LORES 53 = Q3' • AX' • *1 . SEGB 54 = Q3' • AX' . *1 . VID7' NOT DELAYED HIRES 55 = Q3' . AX' . *1 . CLR REF • HO' RIGHT DISPLAY EDGE CUTOFF 56 = Q3' . AX • RAS" . *1 . VID7 • if SEGB' • GR" HIRES DELAYED LDPS' .:i;?- Timing Generation and the Video Scanner 3-23 SWITCHING SCREEN MODES IN TIMED LOOPS A horizontal scan in the Apple takes exactly 65 at address $C019. VBL goes high just after the last machine cycles of the 6502. A vertical scan takes displayed address is scanned at the bottom right of exactly 17030 machine cycles. This information can the Apple screen, and it goes low at the same hori- be used to switch screen modes in timed loops to g:ive zontal point in the last undisplayod horizontal scan apparent combination screen modes. at the top of the screen. Either of these points can be For example, the screen can be split so that half of located within an accuracy of seven MPU cycles by each horizontal line is LORES and the other half of simply polling VBL'. For example, when the follow- each horizontal line is HIRES by switching between ing polling loop falls through, the display scan wiU modes in alternating' 33- and 32-cycle loops. Sim- be from zero to six cycles past the end of VBL. and ilarly, the screen can be split so that half of all the from 19 to 25 cycles before the first display memory horizontal lines are LORES and the other half are is scanned. HIRES by switching back and forth every 8515 cycles. The latter can be accomplished usinsr the sample programs listed in Figures 3. 11a and 8.11b. VBLOFF EQU $C019 MINUS =>=> VBL PLUS VBL' The assembly language program of Figure ^.11 a. POLLl LDA VBLOFF when assembled, is a subroutine that performs the BMI POLLl FALLVBLTHROUGH AT screen splitting. The BASIC program of Figure 3.11b sets up a color display and calls the machine POLL2 LDA VBLOFF language subroutine. BPL POLL 2 FALL THROUGH The example program causes the Apple to be in LORES for 131 TV lines and in HIRES for U\ TV AT BEGIN VBL' lines. The display is aligned vertically by holding Once (hispoint is located, a program can (lerform down any key on the keyboard. The result of running a switching action in the blanking period before any this program is the split screen display pictured in horizontal scan line by wailing for fi5 cycles per Figure 8.14. horizontal scan. The following oxamiile provides a In the Apple He, it is possible to read the state of stable display of HIRES graphics for the first 9(i VBL' (the inversion of the Vertical BLanking gate) lines and LORES graphics for the secon VBL', PLUS => VBL EQU $C057 LORES EQU POLLl LDA $C056 VBLOFF BPL POLLl LDA HIRES FALL THROUGH AT VBL' 4 CYCLES LDX 2 CYCLES JSR WAITXIK 6000 CYCLES (SEE FIG 3.11a) LDY #6 2 CYCLES JSR #23 WAITX10 230 CYCLES LDA LORES P0LL2 4 CYCLES; 6242 CYCLES = 55 x 96 + 2 LDA VBLOFF BMI POLL 2 FALL THROUGH AT VBL BPL POLLl f, ■T ■1 3-24 Understanding the Apple He tsm0 SCRE™ ...inin, ...... ...... SOURCE file: split ) *. 2 00^3 ?w Hrm-;!i/LORE.S SPLIT * Mm * 851S/aS15 * mm » BY JIM SAFHEBi 2/15/1S83 * * aaoa 7 mm a 9 ^........,. CBBD B3U VJJS scauiJ coia 18 Klil:STKB cai4 u KHI) 5Ca54 scuia CB^6 amn 12 13 **l/)REb PftGEl THi!^ EUU $Ca56 0000 U * EVBBV PROGHAM lUGGLF.S THE H1RE.S/L0RES SWITCH 8515 CYCLES . 0000 mm 15 16 * IS SPLIT SCHEEU.0BJ8 043Jl-rM' n FTr.F HAMR ORG IFdB: 'j6 HE"^'' 3PL1T 1F08:AC 14 PACtl 27 19 SLEW LDY siFse lFe3:ft0 u-a5;2e LDV (39 ;SLEM SCBEEN IF KEY PRESSED. u-aB;Ac 27 2a JSR WAITXia le F3 21 LUY se ca 22 KEYCHK KBDSTHB KBU LFei3;AC CM IFOE: W la 23 LIIY BMI ni Ctl 21 HX SLEW IF 11 ; TOGGLE HI SES/WRES SWITCH 01 AM) IFIB:6'J TAX • sal lrl2:2') LF14:1A 21. [J)RES,X 11 lFl^:[iC HU 28 [JJf. 1K1H:A2 il If CM .ISK WAITXIK ;WAIT mm CYCLES 1fia;2« IFlinAB Jl 10 1F1F:2B 21 \\ U5V LDV .ISfi WAITXla ;WAiT 498 CYCLES lF2i:l8 \i Ba; IK2):90 lib a 34 • •8 KEYCHK \r'i'>: 1F2S: * TIMIWi: W>UTINFS: IF 1K25: 36 • WAITS102'-, WAITSii-i V-REG TIMES IB CKCLES . 37 2'J • IMIMMUM ' WAIT 20 CYCLES) j3 IF2'j: IK25t 3a 4) * * WAITKIK WAITS X-HB". •ATIMES 1900 CYCLES. IF25: ll-'2'j:ua Bl I--J )■) 39 40 'j1 UWPW iJEY HNK SKIP ' •A IK27:88 41 WAITXla DEV Cli- 44 SKIP ;WAIT Y-BEG TIMES 10 lf28:8i) AZ •ii [fJ'J:EA 48 lF2A:na BNE NOP (J30Pli1 lF2C:6a LF21):1tl f.2 46 [;:^:pik P!JA :f2k:68 ^2 PLA IFJFlEA m-s NOP IFWiLfl 4') 49 m;>p iJJY IF51:A0 WAITXIK DEX «9B ;WArr X-REG TIMES 100B FJ WAITXID 1F1J:2W 27 JSR 47 1F36:EA NOP 1 m :CA IF lF3a:nB UNE ],(»P1K 1F3A:6B Krs •'• SUGCKS^ FUL ASSEMIll.V: NO ERBORS Figure 3.1 la Assembler Listing: Timed Execution Screen Splitting. Locating VBL within seven cycles may not be can be located by detecting VBL on or VBL off, and accurate enough for your application. It would not then waiting an appropriate number of cycles. For suffice for screen mode switching at a specific posi- example, the program in Figure 3.12 will result ina tion during display time. VBL can be located pre- LORES graphics display with a 20-character text cisely by finding the point where VBL switches message in the middle of the screen. from off to on within seven cycles, then slewing Any of the screen splitting routines of this appli- backwards in 17029-cycle polling loops until VBL is cation note can be called from BASIC programs or sensed off. The video scanner state will then be at programs written in other languages. Many varia- precisely one cycle before VBL (scanner = tions ofthese routines are possible. Any number of OlOlUlll/lllllll). VBL switching from on to off unusual Apple displays can be created with a com- can be similary located, and any video scanner state bination oftimed loops and polling for VBL. § Tinning Generation and the Video Scanner 3-25 10 REM 11 REM 12 REM SET UP LORES AND HlRtS AHD CALL !] PL i T SCREEN. 13 REM 14 REM 20 PRINT CHR$ (4);"BL0AD SPLIT SCREEN. OBJa" 30 HGR : HOME : VTAB 21: PRINT "1 7 D 2 8 E B 4 5 A 3 6 C 9 t' 3" 40 DIM COLR(39) ,X(21) 100 FOR A = 0 TO 39: READ COLR(A): CULOk= COLR(A): VL I N 0,39 AT A: NEXT A 200 FOR A = 0 TO 21: READ COLR(A): READ X (A) : HCOLOR= COLR(A) 210 HPLOT X(A),0 TO X(A),159: NEXT A 220 FOR A » 8319 TO 15383 STEP 128: POKE A, 64: NEXT A 300 CALL 7936 400 REM LORES DATA 410 DATA 1, 0, 7, 7, 0, 13, 13, 0,2, 2, 3, 3, 3, 0,14, 14, C, 11,11,0 420 DATA 4, 4, 0, 0, 5, 0, 0,10,0, 3, t), 6, 0,12, 0,9, 0,15, 0,8 500 REM HIRES DATA 510 DATA 4,0,3,20,4,21,3,4 1,4,4 2,7,62,7,3 3,7,104,3,105,7,12 5,3,126,7,159 520 DATA 7, 180, 3, 182, 3, 206, 7, 22i;, 3, 2 3 3, 7, 24 7, 3, 26 2, 3, 26 3, 7, 27y 3,161 Figure 3.1 1 b BASIC Listing: Call Split Screen. 3-26 Understanding the Apple He SOURCE FILE: LIL TEXT WINDOW 0000 ■^ ********************************************** 0000 2 * * 0000 3 * LITTLE TEXT WINDOW * 0000 4 * * 5 * DEMONSTRATES PRECISE VBL DETECTION * 0000 6 * * 0000 7 * Jim Sather 8/15/84 * 0000 3 0000 9 A-ik********* **************** ******^* *********** 002C 10 H2 EQU HLINE RIGHT TERMINUS 0030 COLOR EQU LORES COLOR BYTE C00C 12 11 COL40 BQO $2C 80COL RESET ADDRESS C019 13 VBLOFF EQU $30 $C00C VBL MINUS => VBL', PLUS => C050 14 GRAFIX EQU $C019 C051 15 TEXT EQU $C050 C056 16 LORES EQU $C051 F819 17 HLINE EQU $0056 LORES HLINE SUBROUTINE 0000 18 * $F819 NEXT OBJECT FILE NAME IS LIL TEXT WINDOW. OBJ0 1P00: 20 19 ORG 1F00:8D 0C C0 $1F00 COL 40 SINGLE-RES DISPLAY 1F03:AD 56 27 C0 21 STA IDA LORES 1F06:A9 22 LDA FILL SCREEN USING HLINE 1F08:85 2C 23 STA H2 RIGHT COORDINATE = 39 1F0A:A9 24 IDA #39 1F0C:85 OC 25 COLOR COLOR = HIRES40 GREEN 1F0E:A2 30 2F 26 STA #$0C UJX CLEAR LINES 47-0 1F10:A0 00 27 FILL LDY LEFT COORDINATE = 0 1F12:3A 29 28 TXA #47 ;GET VERT COORDINATE FROM X 1F13:20 19 F8 JSR HLINE 1F16:CA 30 DEX #0 1F17:10 F7 31 BPL FILL 15 1F19:A2 LDX INSERT MESSAGE MSG,X 1F1B:BD 8E IF 33 MSGLP 32 LDA 1F1E:9D Bl 05 34 STA #21 $5B1,X MESSAGE AT LINE 11, POSITION 10 1F21 :CA 35 DEX 1F22:10 F7 C0 36 BPL MSGLP 1F24 :AD 19 37 POLLl 1F27:30 FB 38 LDA VBLOFF BMI POLL! FIND END OF VBL FALL THROUGH AT VBL 1F29:AD 19 C0 39 P0LL2 LDA VBLOFF 1F2C:10 FB 40 BPL P0LL2 LF2E: {2) FALL THROUOl AT VBL' 1F2E:A5 00 42 IDA (3) NOW SLEW BACK IN 17029 CYCLE LOOPS 1F30:A2 11 4341 *LP17029 LDX $00 (2) 1F32:20 84 IF 4 445 JSR WAITXIK (17000) RTSl 1F35:20 8D IF 4 6 JSR #17 {12) 1F38:A5 00 IDA 1F3A:A5 00 (3) 487 IDA 1F3C:AD 19 C0 4 49 $00 (3) IDA VBLOFF (4) BACK TO VBL YET? 1F3F:EA NOP $00 EMI 1F40:30 EE 50 LP17029 ;(2} (3,2) NO; SLEW BACK LF42: 51 1F42:A2 05 52 LDX #5 (2) YES; END VBL IS PRECISELY LOCATED Figure 3.12 Atsemblef Listing: Locating VBL Precisely (1 of 2). M'ii «(?».' Tinning Generation and \he Video Scanner 3-27 1F44:20 84 IF 53 JSR WAITXIK (5000) NOW WAIT 5755 CYLES FOR TEXT WINDOW 1F47:A0 49 LDY (2) 54 55 #73 WAITX10 1F49:20 7A IF JSR (730) 1F4C:48 56 PHA 1F4D:68 57 PLA ;C3) (4) 1F4E:AD FF FF 58 UOA ;(4) $FFFF (2) 1F51:A2 08 59 LDX 1F53:AD 51 C0 60 TXTTIME EDA TEXT RTSl (4) 1F56:20 8D IF 61 JSR (12) WINDOW RIGHT = WINDOW LEFT + 21 1F59:A5 00 62 WA #8 (3) 1F5B:EA 63 TOP $00 ;{2) 1F5C:AD 50 C0 64 LDA GRAFIX (4) 1F5F:A0 03 65 LDY (2) WINDOW LEFT = WINDOW RIGHT + 44 1F61:20 7A IF 66 JSR WAITX10 #3 (30) 1F64 :A5 67 LDA C3) 1F66 :CA 00 68 DEX $00 1F67:D0 EA 69 BNE TXTTIME ;(2) 10 (3,2) SWITCHING TIME = 8 X 65 - 1 = 519 1F69;A2 70 LDX (2) WAIT 17030 - 519 = 16511 1F6B:20 84 IF 71 JSR WAITXIK (16000) BEFORE WINDOW LEFT #16 1F6E:A0 32 72 LDY (2) 1F70:20 7A IF 73 JSR WAITX10 #50 (500) 1F73 :A2 08 74 LDX (2) 1F75:EA 75 NOP 1F76:D0 DB 76 BNE #8 TXTTIME ;(2) (3) 1F78: 01 SKIP 1F78:D0 78 DOOP10 BNE * 1F7A: 88 7977 WAITX10 DEY WAIT Y-REG TIMES 10 1F7B:88 80 SKIP DEY 1F7C:EA 81 NOP 1F7D:D0 F9 82 BNE LOOP10 1F7F:60 83 RTS 1F80:48 84 LOOPIK PHA 1F81:68 85 PLA 1F82:EA 86 NOP 1F83:EA 87 NOP 1F84:A0 62 88 WAITXIK LDY WAIT X-REG TIMES 1000 1P86:20 7A IF 89 90 JSR WAITX10 iF89:EA NOP #98 1F8A:CA 91 DEX IF8B:D0 F3 92 BNE LOOPIK 1F8D:60 93 RTSl RTS XF8E: IF8E:00 95 MSG DFB "*Little SWITCH IN THE BLACK 1P8F:AA CC E9 9694 * ASC $00 1F92:F4 F4 EC Text Window* " 1F95:E5 A0 D4 1F98;E5 P8 F4 1P9B:A0 D7 E9 1F9E:EE E4 EF lFai:F7 AA A0 *** SUOCESSPUL ASSEMBLY: NO ERRORS Rgure 3.1 2 Assembler Listing: Locating VBL Precisely (2 of 2). 3-28 Understanding the Apple lie SOFTWARE APPLICATION APPLE TIMING LOOPS It is not fTonerally known that the fi502 clock of the age machine cycle duration is .9845842925 microse- Apple is not fixffi frcqiioncy, and there is some con- conds. In future PAL-based Apple He's with the fusion mImjuI what that frequency is. This is not 14.25 MHz hybrid oscillator, the averag'e machine cycle duration will be .9846153846 microseconds. important in most Ajiple programs, but the fre- When very precise time measurement is neces- quency ami stal>ility oflhe Mi'U clock are important factors in tirecision timed loop assembly lanjruajre sary, the projrrammer has to consider the impact of f)ro(^ramH. clockpul.se .jitter, which is caused by the long cycle. Since the Apple He has no real time clock, timed The A }iplv II Reference Manual for He Only inac- curately (fives the PHASE 0 frequency as 1.022727 output must be done with prop:ram loops which take MHi!.Thisis]'1.;J1818(lividedby 14,anditwouldbe a specific numiier of clock pulses to execute. When the PHASE (I frequency if there was no long cycle, possible, these bops should be written in multiples The composite frequency of the Apple is 1.02048432 of 65 cycles. This will eliminate loop output jitter. MM^, which is 14,31818 x (65/(65 x 14 + 2)). The < )therwiae the application must be able to tolerate a average period of duration of an Apple 6502 ma- 140-nanosecond jitter. 140 nanoseconds is the dif- chine cycle is .9799268644 microseconds. Thi,s is the ference between a normal cycle and a long cycle. value which should be useci for computing exact The programmer should be aware of Apple clock- time durations of Apple profjrams. In PAL-based pulse jitter and determine its affect on his particu- Apple He's with 14.25045 MHKosciUators, the aver- lar application. Timing Generation and the Video Scanner 3-29 HARDWARE APPLICATION AN APPLESOFT EMULATOR FOR THE TIMING HAL Analyzing the Apple He HAL timing outputs HAL outputs, excluding LDPS' and VID7M. For can be pretty difficult, especially when you begin each initial setting, the emulator prints the num- looking at the LDPS' and VID7M variations. Fig- ber of 14M cycles before the outputs reach the ure 3.13 is an Applesoft program which draws states pictured at the left in Figure 3.14. This timing diagrams of the HAL outputs based on verifies that a given set of HAL equations cannot logic equations like those used to specify a HAL/ cause the timing chain to hang in some invalid PAL program. The program lets you vary the sequence. It takes several hours for the emulator SEGB, gated GR+2', CASEN'. 80COL', and VID7 to scan all the possibilities for a set of equations, so inputs to the HAL and see the resulting timing turn on your printer and bo prepared to wait if diagram plotted out on the HIRES screen. you decide to perform a complete scan. Figure 3.14 shows two sample timing diagrams An interesting design problem that some readers plotted by the HAL emulator. The plotting always might wish to tackle is the right side cutoff of starts with the signals in the states shown at the HIRES delayed video. LDPS' and VID7M logic left of Figure 3.14, and HO always stays low for equations are such that the last video cycie is always two counts after the first time it falls. This results cutoff after Q'.V • AX' (see PHASE 1 during the long in the plotting of the long cycle. If you initialize cycle). It would be preferable if this cutoff was the DOS TOOLKIT HRCG program before run- delayed by one 14M period when the last video cycle ning the emulator, the names of the signals will be is HIRES delayed because, as things are, you cannot drawn on the left side as shown in Figure 3.14. plot orange dots at the far right of the display in The HAL emulator can also serve as a design HIRES4() mode. I grappled with this problem and aid for those persons interested in experimenting was unable to come up with a working set of HAL with alternate timing schemes for the Apple He. logic equations that would solve it, not even if the By changing any of the equation definitions in video generator video ROM was programmed so lines 2000—2470, you can check out how the tim- that HIRES hit 7 mirrored HIRES bit (J. I finally ing signals would look if the HAL were pro- gave u;) on the problem although I wouldn't [pro- grammed differently. Also when you run the nounce itunsolvable. Perhaps a reader more re- emulator, it allows you to specify scanning instead sourceful than I can work it out. No fair rewiring the of plotting. If you select scanning, the emulator motherboard or switching to a 35()-nanosecond video will scan through all possible starting states of the ROM. 3-30 Understanding the Apple He 100 REM APPLE HE HAL/PAL TIMING EMULATOR III ^ BVaiMSATHER 2/14/84 III 150 Z Ri>l 160 REM „.„, 200 REM ********** INITIAL SIGNAL DATA 210 DATA 0,0,0, 1-0. 1'S'^i-e'^'l'^ ,,,^ ^l^lar.;:MSIC«AL,- = W(SIG«AC..) : NKXT III REM ^A^'i r.oll\\Z 230 Z oAn avM ********** TITLES 25 ,X "14M "."^S' ","AX "/-CAS' ","Q3 ;V;PHS0 ;y'PKSl" 255 DATA "m " "CREF ","7M " ,"VID7M" ,"IX)P3' " , -VID? FOR SIGNAL = 0 TO 12: READ TITLE? (SIGNAL) : WEXT 260 DrTJTLES?(U): Ilia ^M ******** CLEAR SCREEN AND PREPARE TO DRAW WAVEFORMS ]l\'y lZ,'-4^E,'f79Jnr^S (SCAN,": GET B? : HOME : IF B$ = "S" THEN NOT OyrO 4000 1040 Z\Z \lll PRINT SLGB- SLGB " "SEgL-"SE(^B 0K° VN UK- -J^ BSI Y/N-rGET > "Y" ^aTHEN^ SEGB : IF B$ „ < .. ^^ = SEGB: GOTO 1040 fg^ gx% : GOTO 1050 1050 PRmT ™::"f .t OK? -^.^^^'l^^l e^ / > .yn THEN CSEN% = ^JOT CSEN%: GOTO 1060 1060 PRI^T ™M = CS^"^,,, ^^o' .-..''^T BS. IF B$ < > "Y" THEN COL80% = NOT COL30%: GOTO 107(J "••"f^R a ='i To 7: PRINT V(X)",";: NEXT : PRINT V(8,;= HTAB 18 \IZ pr!n FNTER V ™ateS v;5r:v(6,,V(7.,V(8):_,PRINT30COL'= : = «:VCNT = 0 in"; V I V(^;?^(3KV(4). GR'="GX%" CASEN' ="CSEN%" COL80* 1094 PRINT "SEGli="SEGB" FOR A = 1 TO 8 : PRINT V(A);: NEXT 10CI6 PRINT - PRINT "VID7=";: ml V™ l! HGR : HCOL0R= 3: PRINT CHR? (17);: REM CTRL-Q HOMES CURSOR 10^9 KOR SIGNAL - 0 TO 12; PRINT TITLES (SIGNAL) : NEXT 1100 RKM 1101 RFM PLOT LEFT TO RIGHT FOR/NEXT LOOP ********** TO X + 2 ,5 TO X + 3,5 1105 FOR X = 36 TO 276 STEP 4: HPLOT X,5 TO X,l TO X + 2,1 = 0: NEXT : NEXT 1120 FV3R SIGNAL = 0 TO 11: FOR TERM = 1 TO 8 :W(SIGNAL,TERM) = W(5,0) 1130 RAS% = W(W,0):AX = W(1,0):CAS% = W(2,0):Q3 = W(3,0):P0 = W(4,0):Pl H0 = W(6,0):CREF = W(7,0);S7M = W(8,0) :V7M = W(9,0) :LDPS% = W(10,0):VID 7 = W(11,0) 1140 2000 REM 2010 REM ********** BEGIN EQUATION DEFINITIONS 2020 REM 2030 R1;M AVAILABLE INPUTS > S7M,CREF,H0 ,VID7 ,SE)GB,GX%,CSEN% ,VD80% 2040 REM OUTPUTS > RAS% ,AX,CAS% ,03 ,P0 ,P1 ,V7M,LDPS% 2H60 REM % IS TAG FOR ACTIVE LOW SIGNALS LIKE CASEN' 2070 REM 2080 REM *•*****•** RAS' (RASI) 2090 W(0,1) = Q3 2100 W(0,2) = NOT RAS% AND NOT AX 2110 W(0,3) = NOT RASI AND CREF AND H0 AND P0 2120 W(0,4} = NOT RASI AND NOT S7M AND H0 AND P0 2130 REM ********** AX 2140 W(l,l) = NOT RAS% AND Q3 2150 W(l,2) = NOT AX AND Q3 2160 REM ********** CAS' (CASI) 2170 W(2,l) = NOT AX AND NOT CSENI 2180 W(2,2) = NOT AX AND PI 2190 W(2,3) = NOT CASI AND NOT RAS% 2200 REM ********** Q3 2210 W(3,l) = NOT AX AND Pi AND t»T S7M 2220 W(3,2) = NOT AX AND P0 AND S7M 2230 W(3,3) - NOT Q3 AND NOT RASI 2240 REM ********** PHASE 0 (P0) 2250 W(4,l) = P0 AND RAS% AND NOT Q3 2260 W(4,2) = NOT P0 AND NOT RAS% 2270 W(4,3) = NOT P0 AND Q3 Figure 3.13 BASIC Listing: An Apple iie Timing HAL Emulator (1 of 2). Timing Generation and the Video Scanner 3-31 2280 REM ********** PHASE 1 (PI) 2290 W(5,l) = HOT P0 AND RAS% AND NOT Q3 2300 W(5,2) = P0 AND NOT RAS% 2310 W(5,3) = P0 AND Q3 2320 REM ********** VID7M (V7M) 2330 W(9,l) = NOT GXI AND SEGB 2340 W(9,2) = GX% AND NOT COL80% 2350 W(9,3) = GX% AND S7M 2360 W{9,4) = NOT VID7 AND PL AND NOT Q 3 AND NOT AX 2370 W(9,5) = NOT H0 AND CREF AND PI AND NOT Q3 AND NOT AX 2380 W(9,6) = V7M AND AX 2390 W(9,7) = V7M AND P0 2400 W(9,8) = V7M AND Q3 2410 REM ********** IXiPS' (LDPSI) 2420 W(10,l) = NOT Q3 AND NOT AX AND NOT COL80% AND GX% 2430 W(10,2) = NOT Q3 AND NOT AX AND Pi AND GX% 2440 W(10,3) = NOT Q3 AND NOT AX AND Pi AND SEGB 2450 W(10,4) = NOT Q3 AND NOT AX AND PI AND NOT VID7 2460 W(10,5) = NOT Q3 AND NOT AX AND PI AND CREF AND NOT H0 2470 W(10,6) = NOT Q3 AND AX AND NOT RASI AND Pi A^D VID7 AND NOT SEGB AND NOT GX% 3000 REM 3020 REM ********** THE FOLLOWING DEFINITIONS ARE EXTERNAL TO THE HAL/PAL. 3040 REM ********** H0 3045 IF NOT RASI OR NOT PI OR Q3 THEN 3060 3050 HCNT = tCNT + 1: IF HCNT < > 3 THEN W(6,l) = NOT H0 : GOTO 3070 3060 W(6,l) = H0: GOTO 3080 3070 REM ********** CREF 3080 IF S7M THEN W(7,l) = NOT CREF 3090 IF NOT S7M THEN W(7,l) = CREF 3100 REM ********** 7M (S7M) 3110 W(8,l) = NOT S7M 3120 REM ********* VID7 3130 IF RAS% AND NOT Q3 THEN VCNT = VCNT + 1: IF VCNT < 9 THEN W(U,1) = V{VCNT) : ODTO 3150 3140 W(ll,l) = VID7 3150 REM 3160 REM ********** DEFINITIONS NOW COMPLETE 3170 REM NOW "OR" ALL THE TERMS FOR EACH SIGNAL AND DRAW THE SIGNALS. 3180 REM 3190 IF NOT SCAN AND P0 AND NOT Q3 AND RAS% THEN HPLOT X,0 TO X,102: REM REi''ERENCE LINES 3195 IF NOT SCAN AND PI AND NOT Q3 AND NOT AX THEN FOR Y = 7 TO 95 STEP 8: HPLOT X - 2,Y: NEXT 3200 FOR SIGNAL = 0 TO 11:Y - SIGNAL * 8 + 13: FOR TERM = 8 TO 2 STEP - 1 3210 W(SIGNAL,TERM - 1) - W (S IGNAL , TERM - 1) OR W( SIGNAL, TERM ) : NEXT TERM 3215 IF SIGNAL < 6 OR SIGNAL = 9 OR SIGNAL = 10 THEN W(SIGNAL,1) = NOT W(SIGNAL,1) 3217 IF SCAN THEN NEXT SIGNAL: RETURN 3220 HPLOT X,Y - 4 * W(SIGNAL,0) TO X.V - 4 * W(SIGNAL,1) TO X + 3,Y - 4 * W(SIGNAL,1) 3230 W(SIGNAL,0) = W (SIGNAL, 1) : NEXT SIGNAL: NEXT X 3240 PRINT CHR$ (4);"PR#2": END 4000 REM ******************************************************************************* 4005 REM 4010 REM SCAN ALL POSSIBLE INITIAL CONDITIONS TO MAKE 4020 REM CERTAIN PAL SYNCS UP CORRECTLY. 4030 REM 4050 SCAN = 1: FOR SIGNAL = 1 TO 7: PRINT TITLE$ (SIGNAL) ; : NEXT : PRINT " X": POKE 34,1 4060 FOR SIGNAL = 0 TO 8:W(SIGNAL,0) = S(SIGNAL) 4070 IF SIGNAL < 7 THEN HTAB SIGNAL * 5 + 2: PRINT S(SIGNAL); 4080 NEXT SIGNAL 4090 FOR X = 1 TO 100:HCNT = 0:CFLAG = 0: GOSUB 1120: REM UPDATE SIGNAI^S 4100 FOR SIGNAL = 0 TO 8:W(SIGNAL,0) = W(SICMAL,1): IF W(SIGNAL,0) < > I(SIGNAL) THEN CFLAG = 1 4120 NEXT SIGNAL: IF CFLAG THEN NEXT X 4140 PRINT " "XJSIGNAL =7: IF X = 100 THEN PRINT CHRS (7) CHR$ (7) CHR? (7) ; : GET B$ 4160 SIQJAL = SIGNAL - I 4165 IF SIGNAL < S THEN PRINT CHR$ (7) "ALL POSSIBILITIES SCANNED": POKE 34,0: END 4170 4130 S(SIGNAL) = NOT S(SIGNAL): IF S(SIGNAL) = 0 THEN GOTO 4160 GOTO 4060 Rguro 3.13 BASIC Listing: An Apple Ite Timing HAL Emulator (2 of 2). 3-32 Understanding the Apple He I 4 f.1 niumnnnniuihJfinnruuuuuuinnnhm^ AX L A S ' q:^ PH PH SI HS CR EF '7M J ID7n rLTUT-Turui TjTJTTJTjnLnjx TLTiJXJnjnj-ijnL T_n_m^^ LD PS ' %r U I D7 S E G E = 0 G R '= 0 C A S E N •= 0 8 0 C 0 L '= 8 1.1 1 D 7 = 1 1 1 0 1 1 0 1 V:: E b B = 0 G R '= 1 CASEH ' =1 80l:ijL ■ =0 U 107=10 100 1 10 Figure 3.14 HIRES Dumps from the Timing HAL Emuiator. chapter 4 _ la^ v I -^ The 6502 00000000 Microprocessor [S SMM3T ^LJ The 6502 MPU (Micro Processing Unit) is the are concerned primarily with the hardware imple- device in the Apple lie which executes stored mentation ofthe 6502 in the Apple He computer. sequential programs. It is a single 40-pin integrated Volumes have been written about various aspects of circuit that executes 6502 machine language pro- the 6502, especially programming.- The choice of grams as it reads them from the data bus. It can be 6502 topics in this chapter was governed by the thought of as the brains of the Apple. unique features of 6502 use in the Apple, and by the The 6502 was designed by MOS Technology in the goal of this book to fill information gaps in Apple mid 1970s as part of their MCS6500 series micro- literature available to the public. processor family. It has been a popular choice as a Manufacturers of the 6502 are: microprocessor for personal computers, being used incomputers produced by Apple, Atari, Commodore, MOS Technology, Inc. Ohio Scientific, Rockwell International, and other 950 Rittenhouse Rd. manufacturers. The6502 gives adequate computing Norristown, Pa. 19403 speed and versatility at a very low cost. Its pro- gramming language is very simple, making it an Synertek, Inc. ideal MPU fortheoccasional computer programmer. P.O. Box 552 The most important 6502 related knowledge for Santa Clara, Ca. 95052 an Apple owner to attain is programming knowl- edge. The ability to read and write 6502 assembly Rockwell International language programs greatly expands the horizons of Microelectronic Devices an Apple computerist. 6502 assembly language is P.O. Box 3669, RC55 not, however, a major topic of this book. These pages Anaheim, Ca. 92803 4-2 Understanding the Apple [le 6502 SIGNALS Addr essa During ndR/W' every machine cycle, the 6502 places an There are 40 pins on a 6502, three of which serve address on its address output. In association with no function. In addition to the address output and the address it outputs, it brings its R/W line high or data input/output, there are four outputs (R/W, low, thereby telling the world whether it wants to PHASE 1. PHASE 2, and SYNC) and six inputs read or write data. With 16 address lines, the 6502 is (READY. IRQ', NMI', PHASE 0, SET OVER- capable of producing 65536 different values at its FLOW', and RESET'). There are three power address output. supply connections. One pin requires +5 volts and The 6502 address and R/W outputs are not tri- two pins require ground. Figure 4.1 shows the 6502 state in the Apple, but these signals are connected to pin assiRnmenls. Figure 4.2 shows the 6502 hard- the address bus through external tri-state bus ware implementation in the Apple. A brief discus- drivers. This enables peripheral cards to gain sion of the 6502 sig-nals with Apple implementation notes follows, access to the address bus via the DMA' line. £>ata Bus Clockpulses- PHASE 0, PHASE 1, PHASE 2 The 6502 has most of its required clockpulse gen- The data input/output of the 6502 is eight lines. eration circuitry built-in. It requires only an exter- This gives the 6502 its overall classification as an nally generated time base which can be implemented 8-bit microprocessor. Data direction is inward in several ways. In the Apple, the PHASE 0 time except during PHASE 2 of write cycles. In the base is developed independent of 6502 internal cir- Apple lie, the 6502 data lines are connected d irectly cuits and fed as the clockpulse input to the 6502. to the data bus. The 6502 generates its required PHASE 1 and PHASE 2 clocks from the PHASE 0 input. PHASE 1 is high during the first half of a machine cycle, and PHASE 2 is high during the second half of a The RESET' input to the 6502 causes the 6502 to machine cycle. PHASE 1 is not thesimple inversion start or restart. A RESET' causes the 6502 to dis- of PHASE 2, There is a slight delay between the T' interrupts and begin program execution at an RESEable PHASE 1 transitions and the PHASE 2 transitions. address stored in locations $FFFC and $FFFD of The rising edge of one always follows the falling ROM. 6502 operation is inhibited while RESET' is edge of the other. The PHASE 1 and PHASE 2 held low. The RESET' sequence begins when clocks are available at pins 3 and 39 of the 6502. RESET' transits from low to high. PHASE 1 and PHASE 2 are not connected in the In the Apple He, the RESET' line is connected to Apple He but are used only inside the 6502. pin 31 of the peripheral slots, to the keyboard RESET key, and to pin 15 of the lOU, A peripheral 1 4Q -^ PHASE 3 card can cause RESET' to drop, respond to RESET', or ignore RESET'. The lOU responds to RESET', VSSiCHOUNDI — 2 S — BESET' but it also causes RESET' to drop when power is NC BEflOlf — — SET OVEflFLOW 36 PHASE 1 -^ IHQ' — — PHASES NC first applied to the computer. nc — — M imy — 35 3T fi;w Interrupts- IRQ' and NMI' SVNC — vcccsn — 6502 MPU ^33 — 02 The interrupts cause the 6502 to stop its sequen- — —01 05 AO — —D3 36 41 — DG tial program execution and execute interrupt han- A2 -^ 30 32 29 D< dling routines. Interrupts are normally associated with input/output functions, but they are a way for A3 -^ 16 a 27 k-07AIS AJ — 26 any type of device to get the microprocessor's atten- AS A6 — — a31 A14 tion. The IRQ' (Interrupt ReQuest) is enabled or A7 AB — — \T n H2 A13 disabled by program control, so the 6502 doesn't K n A9 — have to respond to an IRQ'. The NMI' (Non-Maskable 19 a n ■— V5S (GROUND) Interrupt) cannot be disabled by program control. An — AM An NMI' causes the 6502 to perform an interrupt — sequence after the current 6502 instruction has been Figure i1.1 gr ments. 6502 Pin Assi 21 executed. The 6502 saves its program location count- er and its Status Register (with BREAK flag reset) ■J^^ i^fmi'f^f The 6502 Microprocessor 4-3 ADDRESS 5V BUS R/W vcc -*MDO R/W- -*M01 LS125^*J 34 AO -*DATA MD2 16 ^^9^ D2 BUS 18 OE' OE' 01 03 33 -H-VI *MDS D4 14 B1 00 29 10 A1 32 AO*- A3 30 -^-MDS 11 D5 A1*- A2 A2*- 12 74LS244 -^^ TRI-STATE A5 DRIVER A3-^ 17 ^ 13 A4 A6 C4 D4 *— *-MD6 D6 28 A4-^- 15 14 6502 — *— »-MD7 13 15 MPU 31 27 - -NCNC A5*- 11 , 16 -NC A6*- A7 D7 A7-^ 20 10 5V A8 17 16 18 12:192^ 19 A9 NC -^ NC 35 -*NC OE' OE' NC A8*- 18 36 A10 1 - ;X4 B8 Q irar UPSYNC nmr WV\r Tsmr RESET' 2 2 2 RPI 3,3K 111 .5 SLOT SLOT SLOT SLOT 1 SLOT SLOT SLOT 2 3 4 6 7 Figure 4 2 Schematic: Apple lie 6502 Connections. ^^li?. '■m^ ^K 44 Understanding the Apple lie instruction execution steps (in conjunction withthft' esinter- inanareaof RAM called the stack. Itdisabl at the READY line) and otherwise identifying the op code rupt requests, then begins program execution ry. of a 6502 instruction. The SYNC output of the 6502 address stored in $FFFA and $FFFB of memo is connected only to pin 39 of the peripheral slots in mean- The NM r input to the 6502 is edge sensitive, ition the Apple He. ing the 6502 responds only to a high to low transNMI of NMl' . To gene rate a secon d inter rupt, the line must be brought high, then low again. SET OVERFLOW A high to low transition on the SET OVER- An IRQ' causes the 6502 to perform an interrupt FLOW line sets the overflow flag of the 6502. The sequence after the current instruc tion has been exe- overflow flag is normally set or reset as a logical cuted ifthe program has interrupt requests enabled. result of some 6502 instructions, but the SET The IRQ' sequence is identical to the NMI' sequence, OVERFLOW input forces the flag regardless of except that fheaddressof the IRQ'handlingroutine instruction execution. is stored at $FFFE and $FFFF. The IRQ' signal is The SET OVERFLOW input has limited value not edge sensitive, so the IRQ' must go high before interrupts are enabled again, or the same interrupt as a control input, because it must be used only in will be answered more than once. conjunction with instructions that affect the over- The interrupt inputs to the 6502 are connected to flow flag or in avoidance of such instructions so as the peripheral slots in the Apple. There are no not to interfere with them. It is not connected in the motherboard devices which generate 6502 inter- rupts, and I/O in the Apple He is normally accom- Apple He, plished without interrupts. The Apple He mouse is IRQ' based. Most real time clock cards are capable 6502 CONNECTIONS IN THE APPLE He of generating interrupt requests, and cards which F igu re 4 .2 show s the 6502 hardware implementa- dump Apple memory to disk are based on non-mask- tion inthe Apple He. R/W connections are routed to able interrupts. The IRQ' line is tied to pin 30 of the the address bus through external drivers, and data peripheral slots, and the NMI' line is tied to pin 29. lines are connected directly to the data bus. The READY PHASE 0 clock is PHASE 1 from the timing gener- Bringing the READY input to the 6502 low dur- ator, inverted and gated by DMA' from the peri- ing the PHASE 1 clock in a read cycle causes the pheral slots. All other signals are connected directly 6502 to go into its wait state. In the wait state, the to the peripheral slots. 6502 holds the current address and does nothing. The method of tying the 6502 control inputs to The wait state lasts until READY is sensed high multiple sources is called wire-ORing or collector- during PHASE 2. If the high to low transition ORing. A logical OR function is achieved by tying occurs during a write cycle, the wait state will not lines directly together. As an example, if Slot 0 OR begin until the next read cycle. Slot 1 OR any other slot pulls pin 29 low, the 6502 The wait state of the 6502 can be used for interfac- will sense a non-maskable interrupt. In a wire-GR ing to slow memories, single step operation, slow circuit, the line is pulled high by a voltage througha step operation, or just plain stopping the MPU resistor if no card is pulling the line low. Peripheral indefinitely. It has no impact on the Apple's video cards should not try to pull the wire-OR lines high. circuitry or on RAM refresh, so the video display They either pull the line low or presenta high imped- appears frozen on the screen when the 6502 is halted ance to the line, usually by driving the line with open via the READY line. The READY line in the Apple collector TTL circuits. The 6502 literature specifies is connected only to pin 21 of the peripheral slots. that 3000 ohm pull-up resistors be used for wire-OR This 6502 capability has gone largely unexploited in inputs to the 6502, and the Apple He uses a 3300 ohm the Apple. SIP (Single In line Package) resistor for this function. SYNC The tri-state address bus driver is necessary for The 6502 SYNC output goes high when the 6502 is performing an op code fetch. This is the first cycle in DMA operations connections are because the 6502 not tri-state. The address addressanddrivers R/W' the execution of any instruction in which the 6502 used in the Apple are LS244 8-bit tri-state bus driv- fetches the 1-byte operational code of the instruc- for ers for R/W, the address lines and one fourth of an LS125 tion. The SYNC signal can be used for single The 6502 Microprocessor 4-5 6502 MEMORY USAGE The 6502 also dictates that the highest memory location is $FFFF, and that it will be assigned to Use of the 6502 in the Apple dictates various ROM. That $FFFF is the highest address is an aspects of the memory layout. For example, ad- obvious consequence of the fact that the 6502 has 16 dresses $0— $1FF are always RAM in a 6502 sys- address lines. In asimilar vein, the eight data lines tem. Apart from design dictates, the 6502 also uses of the 6502 dictate that memory is organized into parts of memory so that they are normally not aval 1- able for Apple programs. 8-bit locations. The reason for assigning the highest address to ROM is that the 6502 RESET, NMI. and Pag:eOandPagel($0-$FFand$100-?lFF)ofa IRQ vectors must be stored in locations $FFFA 6502 system must be RAM simply because the 6502 through $FFFF. In particular, the RESET vector has special read/write uses for Page 0 and Page 1. Page 0 locations are used as indirect address loca- in ROM enables the Apple to immediately begin executing a non-erasable program at power up. tions in6502 machine language. Additionally, the Since the 6502 has no special input/output control 6502 has a zero page addressing mode which features, it must control input/output functions speeds and compacts programs making heavy use of with commands decoded from the address bus. In zero page locations for various storage functions. As the Apple, addresses are assigned to the peripheral a result, bigmachine language programs like Apple- slots and built-in I/O functions which could beother- soft BASIC make heavy use of zero page locations. If wise assigned to memory. This is referred to as BASIC isoperatingandyou indiscriminately POKE memory mapped I/O. It was logical in the Apple values into zero page locations, you will deep six design to assign the address space between RAM BASIC. This is because the critical pointers of BASIC will be lost. The following program must and ROM to I/O. That way there are three contigu- crash: ous addressing groups: RAM (.$0— $RFFF), I/O (SCOOO— $CFFF). and ROM (!i!D0OO— .?FFFF). 10 FOR A = 0 TO 2 55 : POKE A,0 : NEXT A : END 6502 TIMING IN THE APPLE lie Page 1 is the 6502 stack. The stack of a micro- proces or isan area of RAM which it uses as a last The 6502 was designed to be similar to the Motor- ola Mr6800 microprocessor, but improved. The in-first out memory. To the computer program, the clock requirements of the 6502 are the same as the stack is like a stack of playing cards which it can discard to or draw from. Coneeptualiy, data is MC6S()()— two alternating positive pulses. In the stored to the top of the stack or withdrawn from the MC6800, the two clocks must be generated exter- nally and input. In the 6502, the two clocks are top of the stack. The stack is actually part of RAM. generated internally from the PHASE 0 clock While the program pushes data to or pullsdata from input. This is one of the 6502 improvements. the stack, the MPU must increment or decrement a The relationship between the PHASE 0 clock read address and keep track of where in memory the input and the PHASE land PHASE 2 6502 clocks is "top|^ of the stack is. In the 6502. the location of the shown in Figure 4.3. The PHASE 1 and PHASE 2 top" of the stack is stored internaily in an 8-bit clocks are not symmetrica! but are low slightly register called the Stack Pointer. When the stack is accessed, the 6502 addresses a location in Page 1 of longer than they are high. The high period of one clock always fits neatly inside the low period of the RAM determined by the Stack Pointer. Virtually all other. The PHASE 1 and PHASE 2 transitions arc machine language programs access the stack via Jump SubRoutine and RelYirn from Subroutine clocked by the transitions of the PHASE 0 input in a repetitive cycle. The falling edge of PHASE 0 is instructions, so at no time can a program indiscrim- followed by the falling edge of PHASE 2 and then inately modify Page 1.* The following BASIC pro- the rising edge of PHASE 1. The rising edge of gram will crash as surely as the earlier one: PHASE 0 is followed by the falling edge of PHASE 10 FOR A = 256 TO 511 : 1 and the rising edge of PHASE 2. To put it differ- POKE A,0 : NEXT A ; END ently, PHASE 0 falling clocks the end of PHASE 2 then the beginning of PHASE 1, and PHASE 0 Exceptions are copy protection schemes which cati for pro- mrtimsng without JSR, RTS. PHP, PLP. PHA, or PLA instruc- rising clocks the end of PHASE 1 then the begin- tions. Inthese schemes, criticai data is stored in Pape 1 of ning of PHASE 2. memory, and ntiost attempts to exam ine memory result in the loss The effect of the long cycle on 6502 clocks is to of the critical Page! data. elongate PHASE 2 by 140 nanoseconds. This has no 4-6 Understanding the Apple lie ~ \ APPLE PHASE 1 f I / APPLE PHASED \ J I 6502 PHASE 1 r 6502 PHASE 2 \ ^ Figure 43 6602 Clockpulse Relationships. , 1 Timing specifications in the 6502 are referenced particular ill effects outside of program timing con- siderations mentioned in the previous chapter. By to the rising and falling edge of the PHASE 2 clock lengthening PHASE 2. all response criteria for (at the .4V point). Important timing specifications communicating with the 6502 become less critical. for Synertek 6502As are shown here, with Mos The following timingdiscussions are valid for either Technology and Rockwell International ratings a normal cycle or a long cycle, but the diagrams shown in parenthesis when they differ: picture normal cycles. The timing specifications of the 6502 are not affected by the long cycle. 1. The 6502 address and R/W' line will be valid The 6502 PHASE 1 clock is not the same as the within 140 nanoseconds (150 nsec Mos Technol- PHASE 1 signal developed in the timing generator. ogy) after the falling edge of PHASE 2. They PHASE 1 from the timing generator is simply will stay valid until at least 30 nanoseconds PHASE 0 inverted. It was named PHASE 1 because after the next falling edge of PHASE 2, The address becomes valid during the first part of of its kinship with the 6502 PHASE 1 clock. Seman- PHASE 1. tic ambiguity is a great way to confuse those who would understand. The term which is distributed to 2. 6502 write data will be valid within lOOnanosec- the peripheral slots, address decode, and RAM is onds after the rising edge of PHASE 2. The PHASE 1 from the timing generator. The 6502 write data will remain valid until at least 60 PHASE 1 clock is used only inside the 6502. In this nanoseconds (30 nsec Mos Technology; 30 nsec chapter only, "PHASE 1" refers to the 6502 PHASE Rockwell) after the falling edge of PHASE 2, 1 clock. Outside of this chapter "PHASE 1" refers to 3. 6502 read data must be valid at least 50 nanosec- the inversion of PHASE 0, distributed from the timing generator. onds <40 nsec Rockwell) before the falling edge of PHASE 2 and must be held valid at least 10 The Apple He uses a 6502 A which has less critical timing specifications than the 6502 (no designation nanoseconds after the fallingedge of PHASE 2. letter) that was used in the Apple 11. The 6502A is PHASE 2 falling is the 6602 data transfer clock, rated for use in 2 MHz computers, but Apple uses 4. The maximum delay between PHASE 0 falling the 6502A in their 1 MHz computer to provide and PHASE 2 falling is 65 nanoseconds. The greater error margins in Apple lie timing.* maximum delay between PHASE 0 rising and *Th6 Apple II Reference Mavualfor Ik Only says that the 1 le uses PHASE 2 rising is 75 nanoseconds. These values a 6502B, and it shows 6502B timing specs in the MPU timing are specified only by Synertek and only with a diagram. Also, the MPU socket on my motherboard is lalwled 100-picofarad load on PHASE 2. 6602B. But Apple applications engineer Peter Baum informed me that it was all a mistake, and that only 2 MHz 6502s (6502As) The time periods represent worst case conditions were used in the Apple lie, Peter also said that the reason for using 6502AS instead of 1 MHz 6502s is that error margins are over an operating range from 0 to 70 degrees centi- grade. Worst case timing specifications are shown increased at a cost of only 10.25 per 6502, in Figure 4.4, Synertek time values are used because f^?W&' 'f»:-'- The 6602 Microprocessor 4-7 that seems to be the brand used in the Apple He, and the Apple He, but one must be wary of an experi- because Synertek values are used in the timing spec- ment with only one sample. The important features ification given by Apple in the He reference man- of Figure 4.5 are: ual.* Also, only Synertek publishes a specification 1. PHASE 1 and PHASE 2 transitions occur for the important PHASE 0 to PHASE 2-delay. Ten nanoseconds could probably be subtracted from the roughly 30 nanoseconds after PHASE 0 failing clockpulse delay specifications to reflect the fact at the peripheral slots. Delays measured from that there is no load on PHASE 2 in the Apple. PHASE 0 rising are longer because the 74S02 The Synertek, MOS Technology, and Rockwell clockpulse gate takes longer to bring its output International 6502s are probably all made the same. high than it does to bring it low (see Figure 4.2), 2. The 6502 address becomes valid at the address When one company gives tighter specifications than bus 124 nanoseconds after PHASE 0 falls at the another, it obligates itself to test its microprocessors using more difficult criteria. peripheral slots. This indicates a setup time of under 100 nanoseconds from PHASE 2 failing. Figure 4.5 is a diagram showing the timing rela- Using the worst case conditions for a 6502A, the tionships actually found in one Apple. The mea- surements were made in an Apple He using a 6502 address in an Apple He will always be Synertek 6502 marked 8307 (January 7, 1983?), valid at the address bus before Q3 falls. 3. Write data becomes valid at the data bus 108 S10891, 370-6502 (no letter designator?). Figure 4.5 may be considered fairly typical of 6502 timing in nanoseconds after PHASE 0 rises. With a 42- nsec delay from PHASE 0 rising to PHASE 2 •See Figure 7-1 on page 142 of the ^ pple [I Reference Mmnta Ifw rising, this indicates a write data setup time of Ik Only, The reference manual timing chart shows Synertek 6502B specifications, and it is inaccurate since it shows the speci- 66 nsec with the Apple in a normal room fications referenced to PHASE 0 falling-. All 6502 specifications temperature environment. 6502 write data must are referenced to PHASE 2 falling. be valid before CAS' falls for it to be read by PHASE 2 lalls 65 nsec maximum attar PHASE 0 tails. PHASE 2 begins to rise 75 nsec maximum alter PHASE Ofises. PHASE 0 PHASE 2 c Read Data must be field valid lOfisec minimum after PHASE 2 falls- Write Data will be heW 60 usee minimum after Address and R^W Write Data Is PHASE 2 [alls. are valid 140 nsec valid KM nsec Read Data must maximum after maximum after PHASE 2 falls. PHASE 2 begins nsecpresent be 50 minimum to rise. before PHASE 2 falls. Figure A A Some Worst Case 6502A Specifications. m^u 4-e Understanding the Apple He s TO ra; CC E ro I g fi 1 at CO CM CO < § CO < < a ■•W'f mi! " ^ The 6502 Microprocessor 4-9 falls the time motherboard RAM. CAS' in the Appleand the the bus), the last valid data on the bus at the bus is 209 5 nanoseconds after PHAS E 0 rises, it was floated remains valid until sets up write data well befor e this. The contr ol. There fore, 6502A brought back under positive e CAS' crite rion woul d bus is float ed just befor e write data valid befor exhib iting worst if the peripheral data data befor e the bus not be met by a 1 MHz 6502 PHASE 2 falls, the last valid ly, the ugh the case timing characteristics. Incidental was floated will still be propagated thro case 1 MHz 6502 woul d not meet this test bus drive r, and the 6502 will still read worst woul d bidirectional the tinii ng in the old Apple 11 either, but the data correctly.* be about 20 nanoseconds less critical RAM becomes APPLE PROGRAMMING 4 Read data from motherboard about 215 nano seco nds befor e ' valid at the 6502 be PHASE 0 falls or about 247 nanoseconds before There are four levels at which programs can chips , PHASE 2 falls. This varies with the RAM written in the 6502 based Apple: 6502 maehcompi me lan- test had OKI Semi con- guage, 6502 assem bly langu age, high level ler and the computer under insta lled. You could The order of ductor 200-nsec RAM chips He, language, and high level interpreter. ult. RAM chips in the Appl e most diffic ult to least diffic use much slower listing is from series and the read data would still be set up long A 6502 machine language program is a ng. Auxi liar y are store d in seque nce in before necessary for 6502 readi nsec of numeric bytes. The bytes mes valid about 80 accesses them by incre- card RAM data beco memory where the 6502 and later, but this is still far ahead of PHASE I menting the address bus reading the program falling. language instruc- while executing. 6502 machine bytes in succession. tions consist of one, two, or three guide lines for moth er- code and possibly 6502 performance creates h comm uni- E ach instruction consists of an op slot devic es whic 3-byte board and peripheral of these guidelines are listed cate with it. Some a 1- or a 2-byte operand. Execution of a the instr uc- below. Specific timing of 6502 communic m chapters ation with instruction requi res three cycles to fetch the instr uctio n. tion plus additional cycles to execu te various Apple devices will be discussed The 6502 has a set of inter nal registers wh ich are covering those devices, so Chapters comm 5-9 should be unication am. A 6502 program play per- studi ed to clari fy the detai ls of 6502 manipulated by the progr by overs eeing the '"ter in the Apple. forms its funct ions b5a^ amon g the internal registers and memory. Theof five be read by a perip heral leme nt is made up 1 The 6502 address can internal register comp er. The ' card befor e Q3 falli ng durin g PHAS E 0 mtim e 8-bit registers and the 16-bit Program Count to trigger a DMA action that same eye e funct ions: clock ed to a following is a list of the registers and their 2. Write data from the 6502 can be E 0. REGISTER FUNCTION peripheral by the falling edge of PHASbus by 50 3. Read data should be valid on the data address of E 2, and Program Counter Contains current nanoseconds before the end of PHAS instruction bein executed. g least 10 nanos econd s after Acc umu lat or Principle arithmetic and should stay valid at fied PHASE 2 has fallen. The minimum speci logical register. is 5 X-Register Index register. PHASE 0 falling to PHASE 2 falling delay Y-Register nanoseconds, and the maximum delay of data Index register. through the 74LS2 45 perip heral slot data bus Stack Pointer Contains current stack driver is 18 nanosecond s, so read data from address. shoul d be valid 63 nanos ec- Stat us Regi ster Contains flags indicating J heral perip onds cards before PHASE 0 falls. 6502 operating modes and instral uctions. data logic results of The requirements for read data being on the in a bus before and after PHASE 2 can be met peripheral card by gating read data with I^^^?; lie hold the previous data SELECT'. This signal does not overlap P^^**^ •AH of the tri-state buses in the Apple d. There are several 2, but the data stays valid on the perip heral data va d or B lone time when they are floate bus and main data bus until after PHAh E £ ^ this charaiscteristic determines operat.or,al o a fea- inH wher some where it necessary for correct operation nrTa nd anyway. When either of these buses is floated {whento device Someofthters eseinstancasarenotedint^^ all devices on the bus present a high impedance of following chap . ''■^^ bM^-^ 4-10 Understanding the Apple He this is an assembler. An assembler takes an assem- Generally, programs cente r around the Accumula- bly language source program and assembles from tor and memory with the X- and Y-registers bemg it a machine language object program. used for address indexing. Values of the Program 6502 programs can be assembled in disk-based Counter. Stack Pointer, and Status Register are Apples using any of several commercially available automatically kept by the 6502 and don't usually assemblers. This is the best way for most Apple have to be accessed directly by the progrPointe am. Provi- owners to write extensive 6502 programs. Com- sions exist for d irect control of the Stack r and pared to almost any computer, minicomputer, or processor status. The Program Counter is contro lled microprocessor machine language, 6502 machine by the flow of the program. language is very simple to use. This extends to 6502 The following is a 3-instruction 6502 machine assembly language. There are only 56 mnemonic language program listed in hexadecimal: codes to learn, and the logical selection of mnemon- OP ADDRESS ADDRESS HIGH ics makes this a simple learning task. CODE LOW The simple instruction set has advantages and AD 89 ID disadvantages. The chief disadvantage is that in 85 1(> some instances a program will require more instruc- 00 tions to accomplish a purpose than it would if power- The first instruction loads the 0502 Accumulator ful special purpose instructions were available. This from address $1D89. The second instruction stores can result in loss of speed and waste of memory the 6502 Accumulator contents at address $16. The space in some programs. One should not get the idea final instruction is a BREAK instruction which that the 6502 is without powerful features. It has a terminates the program. The purpose of the pro- very versatile set of addressingmodes and a decimal gram is to transfer the contents of J1D89 to $16. mode which speeds execution of certain types of Machine language programs may be entered and programs considerably. It's just that there are more executed from the Apple monitor using methods powerful and complex microprocessors around. described in the Ai>i)li' 11 Rcfctrurc Mtnixai for lie Another way to produce machine code involves 0)ih/. the use of compilers. Programs may be written in Assembly language is a way of writing machine high level languages such as BASIC, Pascal, and language programs with computer assistance. Many FORTRAN. High level language programs consist aspects of machine language programming are per- of powerful symbolic commands such as "PRINT" formed better by computer than by humans. Some and "-". A 6502 cannot execute such commands, but such aspects are remembering op codes, addition computer programs (compilers) can examine such and subtraction of addresses, remembering ad- commands and produce 6502 machine language dresses of subroutines, and checking for syntax code which will cause the 6502 to perform the indi- errors. Assembly language assists the programmer cated functions. with these and other details and allows the use of A compiler is like an assembler in that it takes a English language symbology for addresses, oper- symbolic language source program and translates it ands, and opcodes, A prime goal in computer lan- to a machine language object program. It is differ- guage development is English language compat- ent from an assembler in that whole machine lan- ibility. guage routines are generated by a single compiled The same program that was listed above in instruction. Only one machine language instruction machine language is listed here in assembly is generated by an assembly language instruction. language. High level languages are much more powerful than LABEL a? ooDB ADDRESS oorworr assembly language in easing the task of the pro- RESTORE LCft $1D89 RESTORE SAVED POINTER grammer. However, machine language code com- piled from high level languages by a compiler is STA BRK generally less efficient than code assembled from $16 assembly language programs. The programmer has This program contains English language which direct control over the machine code generated in cannot be exectited by the 6502. A computer can, assembly language, and human minds generate however, take this program and convert it to a 6502 more efficient code than compiler programs. With machine language program. A program that does compilers, as with assemblers, symbolic source code ' ,^^lp The 6502 Microprocessor 4-1 1 must be entered with the assistance of a text editor. auxiliary slot. These secondary MPUs greatly The compiler source code must be compiled into expand the possibilities of what one' might find machine language object code before a program can operating in the Apple. Of particular importance is be run. the Z80 card and the associated CP/M operating In some ways, this process of converting a high system. CP/M (Control Program for Microproces- level language program to machine code is a nui- sors) isa disk operating system developed by Digital sance. The object code must be compiled before it Research company for which many programs are can be run and debugged. In an alternate process, a available. The Apple with Z80 card is potentially the high level language program can be interpreted as most important CP/M computer. it is run. The interpreting program examines the high level language commands during program DMA IN THE APPLE execution, and it directs program flow to resident machine language routines which perform the ind i- DMA (Direct Memory Access) refers to a form cated functions. This is the process used with the of fast I/O in which the I/O device directly accesses Applesoft and Integer BASIC languages supplied memory, In DMA, the MPU is removed from the with the Apple He computer. data transfer path between the device and RAM. Both the compiling and interpreting processes There is no program sequence loadingdata from the are available for high level languages in the Apple. source and storing it at the destination. In addition to the Applesoft and Integer BASIC The videoscanner access to RAM while PHASE 0 interpreters in common usage, compilers are avail- is low is a form of DMA referred to as simultaneous able that will compile stored Applesoft and Integer DMA. It is possible because RAM can be accessed programs into machine language routines. These twice as fast as the MPU access in the Apple, and routines will execute much faster than an interpret- because actual MPU data transfers occur only dur- er performing the same function, because the time- ing a short period at the end of the 6502 machine consuming interpretation process is separated from cycle. This simultaneous DMA is completely trans- execution. Compilers and interpreters for other parent to the MPU. It has no effect on program high level languages are also available. execution since it does not affect the 6502 machine Which language should you program in— assem- bly language or a high level language? The answer cycle. A second form of DMA is cycle stealing. In cycle depends not only on the programmer's background, stealing DMA, the clock input to the MPU is stopped experience, and personal preference, but also on the for a machine cycle, and the DMA device accesses requirements of the particular application. Assem- RAM while the MPU is stopped. Thus, a cycle is bly language is fastest and provides the most effi- stolen from the MPU. This type of DMA slows pro- cient use of memory space. Some programs requiring gram execution. speed or large amounts of memory can be written Cycle stealing DMA is implemented in the Apple only in assembly language. Machine code compiled He. The DMA' line is wired to pin 22 of the pe- from high level language source code offers a great ripheral slots, and any peripheral card can directly cornbination of programming ease and speed of exe- access RAM by pulling DMA' low while PHASE 0 is cution. BASIC programs interpreted and executed low and holding DMA' low until PHASE 0 goes high by the firmware interpreter supplied with the then low again. Pulling DMA' low forces the MPU Apple are the easiest of all to write and debug, but address bus driver to a high impedance state and very slow in execution. gates off the PHASE 0 clock input to the MPU. With Whatever language you program in,the6502will DMA' low, even though PHASE 0 goes high at pin be executing machine language code. All of the 40 of the peripheral slots and everywhere else on the important Apple operating systems— BASIC, Pas- motherboard, PHASE 0 does not go high at pin 37of cal, DOS, ProDOS, the monitor, and the Mini- the MPU. The 6502 waits with PHASE 1 high, Assembler— are machine language code which was PHASE 2 low, and inward direction of the MPU originally written in assembly language. data bus connection. The MPU is thus isolated from An important footnote while discussing Apple the address bus and data bus, and the peripheral programming languages and operating systems is card can take control of both buses and the R/W' line. DMA devices should communicate with the tk n»»"*^^'"^ ^^^ "^^^^^ "^^y replace the 6502 via data bus at the end of PHASE 0 as the 6502 does. In the DMA' line or co-process with the 6502 from the '^ r, *lSiJ ■ 'Ho .. 4-1 2 Understanding the Apple He could hold off the clock on a new 6502 for 40 the Appie, PHASE 1 belongs to the video scanner. microseconds, but that as the chip cooked in, this and devices do not respond to addresses except dur- hold-off capability deteriorated. He found it neces- %" ing PHASE 0. sary tokeep new 6502s handy so he could replace the Figure 4.6 shows the timing for stealing a cycle MPU when the Apple started to malfunction. The from the 6502 in the Apple He. The DMA device 6502s were not failing. They were just becoming access is similar to 6502 access. The address bus unable to retain data for 40 microseconds with the should contain a valid address before RAS' rising clock stopped. Mr. Wozniak speculates that the rea- during PHASE 1 so the MMU will have time to son for this is a deter ioriation in capacitance of respond with control of the multiplexed RAM internal elements after the 6502 is run for a while, address bus and CXXX line before RAS' falls.* Mr. Wozniak never determined the maximum reli- Write data to RAM should be set up before CAS' able hold-off time of the 6502 experimentally. The fails, and read data can be clocked to the DMA device by PHASE 0 falling. availability of faster RAM chips enabled him to It would be wise not to steal too many cycles at a design the superior version of the Apple II which time, because if the clock is stopped too long, the was eventually released. His feeling is that it is safe 6502 will lose its internal data, and the program will to hold off the clock to a 6502 for five microseconds, crash. It is not clear how long the clock can be which is the value used in Microsoft's Z80 card for stopped before the 6502 operation becomes unreli- the Apple II.* He also cautions that any experimen- tal determ ination of this capability would have to be able. The MOS Technology data sheet lists the max- imum PHASE 0 pulse width at 520 nanoseconds. performed on new 6502s, used 6502s, and very used This is clearly not accurate because every Apple in 6502s. the world operates very well with a 629-nanosecond It's pretty obvious that the DMA' line can be used PHASE 0 pulse on one out of 65 cycles. The Oshoime for more than just direct access to RAM. Since 6502 Jf & S-B>t Mirroprocenmr Hayidbook (copyright 1981, control of the Apple is via address decode, any McGraw-Hill, Inc. by Adam Osborne and Gerry device controlling the address bus can control the Kane) states that you cannot stretch the PHASE 1 or Apple. For example, a very simple peripheral card PHASE 2 clock on MCS6500 microprocessors. could change Apple screen modes via pushbutton. It Osborne and Kane must have read the same data would just have to steal a single cycle from the 6502, sheet. The Synertek data sheet for SY650X micro- and gate $C05X to the address bus during PHASE 0 processors shows a maximum cycle time of 40 to select a screen mode depending on which button microseconds. This seems to indicate that you can had been pressed. The most common use of the perform DMA in the Apple for 40 consecutive DMA' line in the Apple is to operate an MPU other PHASE 0 cycles without adversely affecting the than the 6502 from a peripheral slot, A Zilog Z80 Apple. The Rockwell International datasheet shows card, Motorola MC6809 card, Intel 8088, or what a maximum cycle time of 10 microseconds which is have you can be plugged in to allow control of the probably a good number. Apple by the owner's favorite MPU, These cards It happens that Steve Wozniak, the original gain access to the Apple via the DMA' line. designer of the Apple II, knows a great deal about The DMA' line has no effect on video scanner this subject. In a conversation with the author, Mr. access to RAM since the video scanner is isolated Wozniak revealed that his first design for the Apple from the address bus. In other words, the scanner II used a different method of scanning memory for access to RAM is transparent to the DMA device, video output than the simultaneous DMA used in his just as it is transparent to the motherboard MPU. final design. When he was designing the Appie II, The 6502 designers intended that the READY RAM chips which could be accessed at 2 MHz were line be used for DMA. Their idea was to stop the just becoming available. As a consequence, the early 6502 in a read cycle, and bring an external tri-state design had a 1 MHz 6502 from which 40 out of 65 address bus driver to high impedance with the cycles were stolen for memory scanning, The 6502, READY line while DMA took place. The READY therefore, effectively ran at about 385 KHz (25/65 x line in the Apple has no effect on the tri-state 1 MHz). What Mr. Wozniak found out was that you *The Apple lie version of Microsoft's Z80 card does not perform •There is no published specification for MMU address bus to DMA, but Is a separate microcomputer with 64K of RAM which multiplexed RAM address bus and CXXX propagation delay. I resides in the auxiliary slot and processes simultaneously with believe, but I don't guarantee, that DMA peripherals will work if the 6502 on the motherboard. The Z80 cannot access mother- they control the address bus before RAS' rising during PHASE board circuits, but both the 6502 and the Z80 can access auxiliary 1. See Chapter 5 for more information on MMU signals. card RAM. ■ '■:'?t;t ; •wrt^*'''/'"'i *'■■ The 6502 Microprocessor 4-13 ^ _l V ■n £^ TO — S57 OLD DATA NEW DATA 25. LDA (S78,X) S57 SBBTB S5T12 OLO 55812 DATA STA (S7a,X) SIBBB SlBBl S72 SF2 ADL $aa9B S8991 ADH ADH, ADL u SAl SIE IGNORE 26. LDA ($79) ,Y Siasi STa SBB71 DATA (NO PX) SBBTB SIBBB 5S792 DATA 27 LDA {SIS) ,1 S72 STA (S7a|,V SIBOB 5B1 SlBBl 573 IGNORE S8OT0 S5B12 u tPX) SEl 578 SaB71 55712 $57 S57 DATA in STA (S7a| ,Y SF2 SBBTB [MO PX) SieOB 50871 DATA SlBBl S5792 W 29 JKP (S5T72) STB ST2 55792 IGNORE (NO PX) S91 SlBBl S1B02 PCL SS772 PCH, PCL SiaaB S57 NEXT OP H JHP (S57FF) S5773 PCH (PX) SlBBB SlBOl S72 PCH sec SST T1BS2 NEXT OP S57FF S57BB W - WRITE CYCLE SFF PCL " - WRITE S6C SST INSTRUCTION CYCLE IP STORING PX - PAGE CROSSING NEXT OP - OP CODE NEXT INSTRUCTION X-REG . $20, y-BEC = $29 STB/STl CONTAIN S57?2 OK S5TF2 AS NEEDED FOR ILLUSTRATION 4-24 Understanding the Apple He »nce ABS IND IND 26 Table 42 6502 Instruction Cross Refer* ABS IND IMP 0PG 0PG SPG ABS I MM X Y X Y 25X REL ACC If 11 12 14 20 20 ADC AND CMP EOR 21 21 27 LDA ORA SBC 16 2 13 15 23 ASL LSR ROL ROR 24 17 BCC BCS BEQ BMI 8,9 BNE BPL BVC BVS 1.9 CLC CLD CLI CLV 1 DEX DEY INX INY NOP SEC SED SEI TAX TAY TSX TXA TXS TYA BIT 12 16 BRK 7 CPX CPY 11 16 DEC INC 13 15 17 23 12 24 JMP 18 29 30 JSR 19 16 11 16 20 LDX 14 20 12 21 LDY u 12 14 21 PHA PHP 3 PLA PLP 4 RTI 6 RTS 5 STA 12 14 16 16 21 21 25 27 22 22 STX 12 14 16 28 STY 12 14 of execution. LDA, DEX, ASL, PH A, and PLA were chosen to represent classes of instructions whose instructions are represented by X-indexed exam- execution sequences are identical. Table 4.2 is keyed ples when Y-indexed execution is identical to X- indexed execution. When possible, LDA examples to T^ble 4.1. To find an example of any instruction are used to represent storing instructions {STA, and address mode, look up the instruction in Tkble STX, STY), and in these examples the write cycles 4.2, then see the referenced example in Tkble 4,1. The op code of all instructions shown in T^ble 4.1 of storing instructions have a "w" following their address. Cycles that are always write cycles have a is assumed to reside at $1000. The X- and Y-regis- ters both contain $20 in all examples, Y-indexed "W" following their address. The letters "PX" stand for Page Crossing. A few examples show the first ' 'I'.jilSSf^-' The 6502 Microprocessor 4-25 cycle of the next instruction. This is indicated by programmer may select a single, double, triple, or "NEXT OP" on the data bus. quadru instrucple tions:strobe by utilizing one of the following At times, the 6502 addresses parts of memory which have nothing to do with a given instruction. STA $C040 One strobe This occurs when the 6502 is performing an internal STA $C040,X {X = 0) Two strobes operation in a cycle and really doesn't need to ASL$C040 Three strobes address anything. Indexing or branching across ASL$C040,X(X page boundaries always results in a superfluous ■ 0) Four strobes* access to an address in the wrong page.* It takes an In BASIC, it helps to be aware of what machine extra cycle for the 6502 to increment or decrement language instruction actually performs the memory the high portion of an address computed across a access when a PEEK or POKE instruction is exe- page boundary. A "LDA $5F72,X", for example, cuted. The following instructions perform the actual takes four cycles with no page crossing, and five memory access in the Apple {where Y = 0): cycles with a page crossing. STA instructions in IDh[$50),Y which the possibility of a page crossing exists allow ^^lesoft PEEK - $E76F STA($50),Y an extra cycle whether the page crossing occurs or Applesoft POKE - $E781 IDA(§CE),Y not. The Synertek Programm ing Manual (May 1 978 ) Integer PEEK - $EEF9 STA($CE),Y states thatthis is necessary to prevent a superfluous Integer POKE - $EET0D write to the wrong address. There are other interesting points about 6502 Correlating the PEEK and POKE instructions with addressing. The read-modify-write instructions examples 26 and 28 of Table 4.1 indicates that (ASL, LSR, ROL. ROR. INC, DEC) always perform POKE instructions generate a double access to the a double write to the valid address.* The first write POKE'd address, and PEEK instructions generate cycle writes the same data that was read, and the a single access to the PEEK'd address. For this second write stores the modified data. Pulling data reason, speaker or cassette control from BASIC from the stack results in a superfluous access to a should be performed by PEEK instructions: "A - wrong Page 1 address. All superfluous accesses to PEEK(-16336)" or "A ^ PEEK(-16352)." As for wrong addresses are on read cycles, and the result- ing data is ignored by the 6502. the C040 STROBE', "A = PEEK(-16320)" gener- Example 30 of Table 4.1 illustrates an obscure atesates adouble strobe, and "POKE- 16320,0" gener- a single strobe. 6502 bug; the JMP indirect instruction cannot fetch The way that high RAM is controlled makes it a the new program counter value from two bytes in prime candidate for sneaky address bus manipula- different memory pages. As shown in cycles 4 and 5 tion. The operation of high RAM is covered fully in of example 30, a "JMP ($XXFF)" gets the next pro- Chapter 5, but a small note about its operation gram counter state from ?XXFF and $XX00, not belongs here. As described in Chapter 5, high RAM from $XXFF and $(XX+1)00 as you would expect.* is configured for writing by two successive reads to Because of this unexpected operation, Apple He $C081. $C083, $C089, or $C08B (see Table 5.5). For programmers should not utilize "JMP ($XXFF)" this purpose, one instruction can accomplish the unless their ultimate motive is to create confusion. same as two. "ASL $C081,X" with X = 0 performs Three software applications of 6502 addressing the same task as "LDA ?C081; LDA |C081". Read- details are in the controlling of the serial outputs, modify-write, absolute indexed, no page crossing nigh RAM, and the disk controller. The speaker and instructions generate two read accesses and two cassette are toggle outputs which are usually made write accesses (one write access in a 65C02) to the w toggle up and down at an audio rate. The speaker, computed address. This is more cute than valuable, lor exainple, should not normally be accessed by but it does illustrate the potential of controlling instructions which make a double or quadruple peripherals by single instruction address sequences access to $C030, because that would result in the in the Apple. speaker hne toggling back and forth at 1 MHz. The A more important application of knowledge of Idea IS to toggle the speaker, wait a thousand addressing detail can be seen at addresses $B82A miCFMeconds or so, then toggle it again. Similar through $B842 of the DOS 3.3 RWTS subroutine. considerations exist for the C040 STROBE'. The $B82A is the beginning of the WRITE DATA rou- tine which writes coded data to a sector of the disk. Statements marked by an asterisk in this application note are Direction of disk operations is accomplished on the *»e for the 6502 but not the 65C02. disk controller by a logic state sequencer, which is a 'm^ ^ '«%■!,: .w-f?' 4-26 Understanding the Apple lie programmed hardware controller. Simply put, page crossing. No doubt, the Apple controller's logic state se- writing data to the disk consists of syncing the writ- ing loop of the logic state sequencer to the writing quencer was designed around the "STA ^COSOX" instruction, since this makes it possible to have the loop of the controlling software. The following pro- disk in other slots besides Slot 6. Given the hard- gram steps check for write protect, and reset the logic state sequencer to its idle location: ware, Apple disk programmers must understand addressing details to program the disk on this level. LDk $C08D,X X = $60 IF SLOT 6. As a reference for those who have a 65C02 in- UCA $C08E,X stal end i thei r Apple He, Tables 4.3 and 4.4 show the EMI WPRDTECT BRANCH IF DISK WRITE instruction execution details of the 65C02. These PKTIBCTEXl tables are nearly identical to Tables 4.1 and 4,2, but The program will fall through the branch if the disk they are different to the extent that 65C02 instruc- is not write protected. From this induced idle state, tion execution is different from 6502 instruction the software can syne itself to the logic sequencer execution. 65C02 instructions and execution cycles with the statement, "STA $C08F,X". This instruc- that are different from 6502 instructions and execu- tion performs a double access to $COEF (assuming tion cycles are printed in boldface in Tables 4.3 and Slot 6). The first access is decoded in the disk con- trol er tocause the logic state sequencer to leave its 4.4.Someof the features of 6502 instruction execution idle state and begin its write loop. The second access that were pointed out in the preceding paragraphs stores actual disk write data in the controller's input/ are not features of 65C02 instruction execution. output register. The controller will only accept data Please note that in 65C02 instruction execution: on the clockpulse after the one which started the logic state sequencer and on every fourth clockpulse 1. Indexing or branching across a page boundary afterward. The writing technique involves writing results in a superfluous read access, but the data in software loops that take^exact multiples of superfluous access is to the program counter four cycles to execute. address rather than to the operand address plus Per.sons wishing to imitate the writing technique or minus 256 (examples 10, 21, etc.). of the RWTS subroutine should not substitute a 2. Read-modify-write instructions result in only "STA $COE F" instruction for the "STA $C08F,X" at one write access to the operand address and a address $B83F of DOS 3.3, "STA $COEF" will start maximum of three read or write accesses to the up the software loop one clockpulse out of sync with operand address (examples 13, 15, etc). the logic state sequencer, and the controller won't 3. The"ASL$C040,X" example thatisgiven above accept the write data. "STA $COEF,X" will work will result in only three consecutive strobes with 0 in the X-register. The instruction must make (example 23). a double access to $COEF. Another address mode of 4. "JMP ($XXFF)" is performed correctly (exam- instruction which will work is a STA (ZP),Y with no ple 30). Jfep 'M' The 6502 Microprocessor 4-27 Table 4^ 65C02 InsTmctions. 1 2 3 < 5 e 7 51991 AODR BUS IGNORE DATA BUS $CA 51991 3. PMX 51090 SPNT H IGNORE DATA 51991 4. PLA 51991re" SPMT SPNT+1 5iaee sgno DATA ?0A IGNORE IGNORE 51991 SPMT SPNTt2 56S SPNT-H PCH, PCL IGNORE NEXT OP IGNORE IGNORE PCH 6. BTI ?15 51«»9 S1991 SPNT SPNT+2 SPNT+1 SPNT+3 PCH,PCL<-1 PCH. PCL IGNORE IGNORE STATUS STATU? PCL PCH 54(1 NEXT OP 7. BRK INGORE SPNT 51891 W .PCL SPNT-1 H SPNT-2 5((! 51«a0 W IROLO SFFFF IHOHl 5FFFE 8. BEQ $10 51e91 51992 NEXT OP 519 5F» 519 592 5I»»« 5iaei 51992 IGNORE 51812 OP NEXT (2-li 5Fe Slfl S0FF5 OP NEXT 5iaBi 51992 (Z-l) (PltJ IGNORE I51lf2 CHORE 11. LDA #$KA I.*?. 5F« 51991 5F3 $1««2 IGNOFB D 12. LDA S7a 51999 51991 59979 w SUM D 5AA DATA ICHORK 13. ASL 57a 51999 .?.7« , 59I!79 OLD DATA $B97f 5a«79DATAH 51991 OLD DATA NEW 14. LDA S7B,X STA S7a,X 51999 51991 51(91 59999 u $1((2 D ?A5 DATA ICNOKE 15. ASL S7fl,X SB5 579 59999DATA $>(«( 51999 51991 59990 M ?(!6 579 «lf«l S7» S7» OLD OLD DATA NEW DATA IS. LDA 55772 579 55772 w S1B99 51991 51992 519(3 D STA S5772 DATA I CHORE 17. ASL S5772 51999 ^1991 51992 55772 W SAD S9B 572 572 557 55772DATA OLD DATA HEW DATA OLD le. JMP 55772 51092 55772 S199B 51991 NEXT OP S5772 19. JSR 55772 572 SPKT 557 SPNT W 5PNT-1 W 51902 S1999 S1931 IGNORE 510 S92 2». LDA 55772, X 529 51999 55772 OP NEXT 51991 51092 $iaa3 {NO PXl 572 55792 IGNORE D 572 DATA 21. LDA 557F2,X 51999 $1991 51092 557 STA 557F2,X SF2 557 519I2 55S12 u 5i((] D IGNOliE 22. STA 65772, X 5BU DATA 557 (NO PX) 51999 51991 51092 55792 IGNORE DATA 557 S5792 W 23. ASL SS772,X 51991 51992 572 S5792 55792 55792DATA « (NO PX) 51099 557 OLD DATA OLD DATA HEH 24. ASL S57F2,X 59D 557 (PlCl 25. LDA (578, X) SIE ■5l99r" 572 OLD S5B12DATA 55812DATA OLD 55812DATA W HEW $1099 5P2 51B91 ADH, AOL w Si»a2 D STA (S7a,X) 51911 ADL 26. LDA (578) ,1 51E 57B 557 57i 59999 ri-i«2 557 ^ • ADH 50091 DATA ignore iiaafp 59970 59971 S5792 51(«2 D (NO PX) SAl S1901 DATA IGKOBE «. LDA li-!i),1 STA (S7B),Y $190^ 51891 579 55612 w 9iaa2 D 59979 572 50071 $•871 IGNORE (PXl SBl 557 DATA ?B1 28. ETA (S7a),i( 57§ 51991 5P2 51999 59970 50371 $««71 $57 55792 W (NO PXl 557 DATA 557 PCL 29. JHP (55772) (NO PXl ML— 5199? 579 51902 PCH PCH, PCL HEXT OP 51991 572 51l«2 39. JMP (SS7FF) 51999 557 55772 S57T3 PCH, PCL 51991 51902 sssai 56C 557 557 $19(2 PCL PCH .Ti. ^ (PX) (47i) LDA 572 S57PP NEXT OP $1**1 $M7< S((71 51992 D STA (S7il DATA S5772 IGNORE 3S. JHP (J5»J,X( 572 PCH , PCL flB2 5FF ?57 SS792 PCH NEXT OP $l«ll $1.II2 551 PCL $5793 57* «1»2 33. BBS! ilt.ill" Siii* 57C S57 557 «57 Sl((2 51*ll «72 S72 5M7« NEXT OP 5B97t 34. BBSl 471, «lf* do PI) SSF $«a7« sia $1(193 SlSit Sl««l «7« $(«7< IGNORE 51913 $72 $1992 $i«a3 HBXT OP (PX) $iia« S9F SlMl $«I7I sr3 IGNORE NKXT OP 57* 5((7) $1(»2 $1« $ica3 IGtIORK 518(3 $fPF6 3t. *13, *XB " «lf» 59P 572 572 $7( 572 37. in. *xr "* isc 8S772 •* $•3 51M1 81»2 $fF72 IGHOKE ignoue IGNORE ICHORE $PPPF IGNORE SFFFF SFFFF SFFFF 85C 972 SS7 ?72 « - HRITE CKCLE HEXT OP - OP CODE NEXT INSTRUCTION w - WHITE CYCLE IF STORING INSTRUCTION • - AVAILABLE IN ROCKWELL BUT NOT NCH 65Ca2 D - ONE ClrCLE EXTENSION OF ADC OR •• - [JNUSED OP CODES (HOPS) IN ALL 65C92 SBC IF DECIMAL MODE ••• - UNUSED OP CODES (HOPS) IM NCR 65C92 ONLI P - PAGE CROSSING X-HEG - 529, Y-HEG - 529. *'8/S7l cont«in 55772 Ol 557F2 as needed for illustration. Boldfaced type is used wher^ t5C92 is different from 6592. ^feiu,' ■^&. ''' 'JSiirFi, ;9f4.,,, 4-28 Understanding the Apple lie UPG Table 4 A 65C02 Insf rucilon Cross Reference. REL 0PG BPG IND 0PG 31 ABS ABS ABS IND IND IHD 21 IMP REL I MM ACC 0PG 0PG 0PG ABS ABS IND 2b * X V 23X Y X Y X 11 12 14 16 20 2B 25 ADC AND CMP EOR 21 27 LDA ORA SBC 17 "'a ASL LSR ROL ROR 2 IJ lb DEC INC 24 35 BBRn BBSn •* 34 BCC BCS BEQ BHI 3,9 BNE BPL BVC BVS 10 BRA 9 CLC CLD CLI CLV 1 DEX DEY INX INV IB 20 NOP SEC SED SEI TAX TAY TSX TXA TXS TYA BIT 11 12 14 16 21 BRK 7 79 cpx cpy 11 12 16 JMP 16 3J IH 20 JSR 19 LDX 16 21 33- LDY 11 12 14 20 12 11 14 21 PHA PHP PHX PHY 3 PLA PLP PLX PL¥ 4 RHBn SMBn ** 13 RTI 6 21 RTS 5 STA 12 14 16 21 25 27 31 16 22 22 28 STX 12 14 STY 12 14 15 1 STZ 12 16 21 14 22 TRB TSB 13 17 02 22 42 62 11 82 C2 E2 *** X3 XB *** X7 XF**** 12 **** 44 ** 14 36 54 D4 F4 37 *** 5C *** 16 DC FC Id SX7, £ * unused op codes 5X3, $XB, S5C (NCR and Rockwell) at generate abnormal addressing modes. ;C02 but not NCR ** BBRn, BBSn, RMBn, and SMBn are found on Rockwell 6 J2. *** unused op codes for NCR and Rockwell 65C02. 65C02. *•** unused op codes for NCR 65C02 but not Rockwell 65C{ XF {NCR 1 '*** .-a«' The 6502 Microprocessor 4-29 HARDWARE APPLICATION D MANUAL CONTROLLER How many times have you been working with data via the data bus. It can only turn the drives on your Apple and had to look up control addresses to and off, select between drives, configure the disk select HIRES NO MIX or LORES MIX or any other controller for different functions, and position the screen mode? It's too bad, but screen mode selection head. Please take note that turning a drive on and isn't supported in the Apple firmware by escape setting READ/WRITE to WRITE will clobber the codesor similarly easy interface. The Apple scheme data on a disk which is not write protected. It is of controlling operational features via soft switches suggested that you experiment with no disk or an is extremely effective for control by programs, but unimportant disk in the drive. Manual control of the the operator at the keyboard is left without means of disk drive is educational, but its only practical func- direct control unless the operating program sup- tion would be to assist in the development of ad- ports it. This application note describes a simple vanced disk programs and formats, or to aid DMA controller which allows the operator to over- maintenance technicians and disk hardware devel- ride program control and manually select among opers. Incidentally, to step the head, turn the phases the Apple features, including screen modes. I call on and off sequentially while a drive is rotating. this circuit D MAnual Controller. Not everybody Stepping through the phases in ascending order likes dis name, but dat's not my problem! moves the head toward track 34. Stepping in de- Figure 4.7 is a schematic of D MAnual Controller. scending order moves the head toward track 0. It works by stealing a single cycle from the 6502 and D MAnual Controller is based in hardware, and placing an address in the $COXX range on the overrides program control. You can select features address bus. This action is initiated when the opera- atany time, no matter what software or firmware is tor presses one of eight pushbuttons (or four momen- running. This can be very convenient for program- tary on-off-on switches). Six slide switches (or six mers while they are developing programs. The Con- DIP switches) configure the Controller so the push- troller does not lock out program control, though, so buttons will affect different Apple features— screen programs which repeatedly select a given mode will modes, annunciators, disk drives, memory configu- not appear to be affected when the Controller de- ration, etc. The concept is to place the operator selects that mode. In the Apple He, there is no way to switches on a small remote panel, connected by a lock out program control of the $COXX control 16-wire ribbon cable to the cycle stealing peripheral functions. card. Figure 4.8 is a photo of an earlier prototype which controlled screen modes only. Circuit Operation D MAnual Controller can control some peripheral The heart of D MAnual Controller ia a 74LS148 card functions as well as motherboard features. priority encoder which detects a button push and Those peripheral card functions which can be con- converts it to a 3-bit address. This address is latched trolled are the ones normally programmed using in a 74LS374 when a button is pressed and placed on DEVICE SELECT' addresses such as RAM card, A2, Al, and AO of the address bus at the first oppor- firmware card, and disk controller management. tunity. The state of A7— A3 of the address bus and Tables 4.5 and 4.6 are an operational summary of D R/W during the DMA cycle are determined directly MAnual Controller showing how some features are by the six configuration switches. A15— A8 are controlled. Some of these are only educational or always set to 1 1000000 during the DMA cycle, yield- cute, while others, like screen mode control and ing an address in the $COXX range, the critical memory configuration, can be very useful. It is control range of the Apple. recommended that the configuration switches be Pressing any of the pushbuttons causes the signal left in the position in which you will most often need at pin 14 of the LS148 to go low. This signal is them, so you will have convenient manual control of debouneed and inverted and sent to a 74LS195 shift the features which are important to you. register for single cycle generation. If the DMA Even though T^ble 4.5 shows how to control Slot 6 priority input is low, the shift register will shift the disk drives using D MAnual Controller, it doesn't button press signal through, and a 1-cycle negative follow that disk I/O can be performed manually. D signal will be felt at pin 2 of a 74LS74 flip-flop. The MAnual Controller is not capable of transferring LS195 is clocked by PHASE 1 rising, so this 1-eycle 4-30 Understanding the Apple He 16 PIN DIP -(17)a15 JUMPER TO PANEL SWITCH 74LS125 QUAD DRIVEH Figure 4.7 Schematic: D MAnual Controller. The 6502 Microprocessor 4-31 D MAnual Controller supports the DMA priority chain so it can operate with some other peripherals which perform DMA. It respects the DMA priority inputand will delay its access until a higher priority device has finished its DMA. It also will steal cycles from a lower priority DMA card if that card respects its priority input. Supporting the DMA priority chain is a little dif- ficult, because it is the most abused protocol since "do unto others..." Apple abused itby not publishing a protocol, and by using the DMA priority chain in the 12K firmware card. Microsoft abused it in their older, DMA based ZSOSfi/'rarrf by requiring higher priority devices to wait several cycles after bringing the priority line low before the Softcard will get off the bus. Yet when the Softcard takes over the bus Figure 4j8 The Breadboarded Manual Controller. itself, it gives lower priority DMA cards no similar consideration. Some DMA based MPU cards don't support the DMA priority chain at all. Other DMA signal falls and rises just after PHASE 1 rises. The cards support or ignore the DMA priority chain in cycle is further delayed for one hal f of a 7M period in ways which make sharing of the DMA capability thefirstha!fofthe74LS74. The resulting signal at unpredictable. pin 5 of the LS74 represents the DMA cycle. When the DMA cycle signal at pin 5 of the 74LS74 D MAnual Controller gets around the unpredict- ability ofother DMA card designs by monitoring goes low, the DMA' line is brought low. Half of a 7M the DMA' line and delaying its own DMA cycle if period later, the data enable signal (LS74-9) of D DMA' is being held low by another card. This should MAnual Controller's address bus drivers drops low. work with other DMA designs which make any This delay allows the MPU to be isolated from the attempt to support the priority chain. Here are some address bus before any attempt is made to control ways to install D MAnual Controller with other the address bus. At the end of the DMA cycle, the DMA related cards: opposite order is observed. Because of propagation delays in the LS09feedingthe DMA' line and moth- 1. Z80 Softcard. The Apple He Z80 Softcard erboard IC Cll, control of the address bus is resides in the auxiliary slot and does not per- released before the MPU address bus driver is form DMA. D MAnual Controller does not enabled. interfere with this card in any way. The older Table 45 Operation of Soft Switcties from D MAnual Controller. AAAA A BUTTON BUTTON BUTTON BUTTON RW 7654 3 FUNCTION 6/7 0/1 2/3 4/5 W 0000 He MEMORY MANAGE RAMWRT INTCXROM W 0000 80STORE RAMRD He I^MORY MANAGE ALTZP SL0TC3R0M 80COL ALTCHARSET X 0010 CASSETE OUT TOGGLE PUSH ANY BUTTON X 0011 SPEAKER TOGGLE X 0100 PUSH ANY BUTTON C040 STROBE PUSH ANY BUTTON 0101 0 SCREEN MODE CTRL 0101 GR/TXT NMIX/MX PG2/PG1 LORES/HIRES AN3 ANNUNCIATOR CTRL AN0 ANl AN2 0101 DOUBLE-RES GRAPHIX 1000 ENA/DSBL FIRMWARE CARD CTRL 1110 DISK HEAD CONTROL ENA/DSBL ENA/DSBL ENA/DSBL ENA/DSBL 1110 DISK CONTROL PHASE-0 PHASE- 1 PHASE-2 PHASE- 3 OFF/ON DRIVE 1/2 SHIFT/LOAD READ/WRITE 4-32 Understanding the Apple lie Table 4A Selection of 16K RAM Card or lie High RAM from D MAnuol Controller. BUTTON 3 OR 7 AAAA A RW 7654 3 FUNCTION BUTTON 0 OR 4 BUTTON 1 OR 5 BUTTON 2 0R 6 READON R 1000 0 BANK 2 CTRL READOFF READOFF - WRTOFF WRTCOUNT+1 READON - WRTOFF READON WRTCOUNT=0 WRTCOUNT+1 WRTCOUNT=0 W 1000 0 BANK 2 CTRL READON - WRTOFF READOFF READOFF - WRTOFF WRTCOUNT=a READON WRTCOUNT=0 WRTCOUNT=0 READOFF WRTCO[JNT=0 WRTCOUNT+1 R 1000 1 BANK 1 CTRL READON - WRTOFF READOFF - WRTOFF READON WRTCOUNT=0 WRTCOUNT+1 WRTCOUNT=0 W 1000 1 BANK i CTRL READON - WRTOFF READOFF READOFF - WRTOFF WRTCOUNT=0 WRTCOUNT=0 WRTCOUNT=0 WRTCOUNT=0 quirkLoader and other memory expansion cards SofU-anI which plug's into a peripheral slot does which use the DMA priority chain to prioritize perform DMA. If you use this type of Softcard, then install D MAnual Controller in a higher multiple card configurations. 3. Disk or Cassette I/O. Disk and cassette I/O in priority siot. It wili steal a cycle from the Sofi- the Apple are normally performed in precise cnrd without affecting its operation. Switch S2 timing loops. Any DMA device which is acti- on the Softrnrd must be on for this configura- vated in the midst of such loops will interfere tion to work. Solder the He jumper on D MAn- with them and the associated data transfer. ual Controller if operating in an Apple He, but leave the He jumper unsoldered if operating in Therefore, you should never operate a pushbut- ton of D MAnual Controller while cassette or an Apple II.* Other peripheral slot MPU cards which support the DMA priority chain should disk I/O is being performed, especially during work in this configuration. write operations. Some hard disk or eight inch 2. Firmware Card. Apple's 12K firmware card floppy disk Apple interfaces are DMA based. uses the DMA priority line even though it does Any such devices should probably be mounted not perform DMA. Since D MAnual Controller in a higher priority slot than D MAnual Con- only needs a single cycle, it will work with a trol er, so that if they support the DMA priority firmware card enabled in a higher priority slot. chain, the integrity of disk data transfer will be insured. It just waits until the MPU accesses a non-ROM address, then steals a cycle. If a secondary MPU 4, DMA cards which do not support the prior- card like the Soffrard happens to be in a lower ity chain. Cards like these are like citizens who priority slot, the firmware card can interfere do not meet their responsibilities to society. Do with that card's operation. This can be pre- not operate the pushbuttons of D MAnual Con- vented by opening the DMA IN jumper on D troller when such cards are active. Only one MAnual Controller. Lower priority firmware card at a time can perform DMA in the Apple. cards are not interfered with by D MAnual Con- Readers who wish to are encouraged to build D troller, because the Controller does not generate addresses in the firmware card range. The MAnual Controller for their own use. They may also firmware card rules also apply to the SCRG purchase the Controller, assembled and tested. The Controller is being manufactured by the Southern *In the Apple He, 3,'?00-ohm pull-up resistors are used on the California Research Group, Readers of this book wire-OR lines instead of 1000-ohm resistors. This results in a may order a D MAnual Controller by contacting; switching time which is too slow for stealing cycles from the D MAnual Controller Sitflenrd. Soldering the He jumper will speed switching time by parallelinK the 3.'?00-ohm motherboard resistor with a 1500-ohm Southern California Research Group resi stor. If other DM A card desiRners begi n to add th is 1500-ohm 13793 Christian Barrett Drive resistor, the He jumper should only be connected on one of the Moorpark CA 93021 cards. Incidentally, D MAnual Controller is a good candidate for installation in SlolSof the Apple lie, because it will work in Slot (805) 529-2082 3, even though a RAM/80-column card is plugged into the auxil- (800) 821-0774 In CA, for orders only iary slot. (800) 635-8310 Outside CA, for orders only chapter 5 RAM and Memoiy Management One might think that RAM and its associated cir- this broad control function as memory manage- cuitry should be a relatively easy subject. You write ment, and as will be seen, managing RAM in the to it and read from it. What else is there? Apple memory. is the ma.jor part of the task of managing lie Well, the MPU does write to and read from RAM. but the video scanner reads from RAM too. Addi- In this chapter, we will examine the requirements tionally, both the MPU and video scanner access of the 64K dynamic RAM chip, and the ways in auxiliary card RAM.* And then there is the 64K wh ich they are met in the Apple He. We will also see dynamic RAM chip with its ROW address, COL- how the MMU monitors the address bus to manage UMN address, and refresh requirement. Add all of map.overall configuration of the Apple He memory the this to the most involved bank switching scheme ever imagined and you have a lot of functional and operational complexity. THE 64K DYNAMIC RAM CHIP When RAM is accessed by the MPU, motherboard circuitry must activate signals which tell the RAM 64K RAM chips are 65,536 bit read/write memo- chips to pass data to or receive data from the data ries. As is indicated in the bus structure diagram in bus. Control of Apple lie data bus communication is Figure 2.7, it takes eight chips to make up the 65,536 the task of the MMU. An MPU program configures bytes of read/write memory on the Apple He moth- the Apple memory by setting up MMU soft switches, erboard. This -Standard chip is available from a and when the MPU accesses an Apple He device, an number of manufacturers in a variety of speeds. MMU data bus management signal either directly With a 2 MHz access rate, the Apple does not put a or indirectly activates the device. Apple refers to particularly stringent speed requirement on its RAM. 'MostdiscussionnfRAMin Ihidfrxtn ml ingthe Apple lie assumes The RAM chip is a 16-pin device requiring two thata 64K RAM card is installed in the auxiliary slot. power supply inputs, +5V and ground. Figure 5.2 6-2 Understanding the Apple lie shows the pin assigninents of the 64K RAM chips and the video scanner, PHASE 0 and RAS' provide (see RAM chip F6). There is a data input to accept the timing reference for scanner ROW/COLUMN write data, a tri-state data output to transfer read addressing and for MPU ROW/COLUMN address- data, and a R/W control input to identify read and ing, RAS' and CAS' are applied directly to the RAS' write cycles. and CAS' inputs of all of the motherboard RAM It takes 16 bits to address 64K of RAM, but there chips, but CAS' does not fall during PHASE 0 are only eight address inputs to the RAM chip. The unless the MPU is accessing motherboard RAM, On 16-bit address must be multiplexed onto the 8-bit the 64K auxiliary RAM card, RAS' is applied to the RAM address input lines in the form of a ROW RAM chip RAS' input, and Q3 is applied to the RAM address followed by a COLUMN address. Think of chip CAS' input. the 65.536 mennory cells as lying in a 256 x 256 RAS' falling clocks the ROW address to the RAM matrix.* The first 8-bit address input to a RAM chip chip. The address input to the chip must contain the specifies which ROW the addressed cell lies in, and ROW address when RAS' falls and the COLUMN the second 8-bit addre.ss specifies the COLUMN. address when CAS' falls. Placing the correct ad- RAS' falling clocks the ROWaddress to RAM. CAS' dressing signals at the address input to the RAM falling clocks the COLUMN address to RAM and chips is the function of the RAM address multi- initiates the read or write action. plexing circuitry in the lOU and the MMU. CAS' Figure 5.1 shows the tinriing' ffenerator signals initiates the data transfer by dropping low after which control RAM access in the Apple. The nature RAS' has already dropped low. Motherboard RAM of these signals is dictated by 64K dynamic RAM must be capable of responding to a read access chip requirements, 1 MHz 6502 timing require- within 374 nanoseconds of RAS' falling and within ments, and the alternating access between the MPU 234 nanoseconds of CAS' falling. Auxiliary card RAM must be capable of responding with read data within 356 nanoseconds of RAS' falling and within * As mentioned in Chapter 2, thishiiok refers to a unit of memory 147 nanoseconds of Q3 falling. The motherboard which .stores a hit of information as a cell. Each RAM chiji has Hr^rjIiB eells. and is capablt' of storing ()r>.,5S(i bit.s of information. and auxiliary card requirements are met by 200- nanosecond or faster 64K dynamic RAM chips, TheeiRhtassot'iatt'di'ollsu'hieh.stjirea byte of information in the Aiijilc are referred to as a memory location. The A])[)le lie has which means they are met by any 64K dynamic (),'■>,:■).'!(! R.AM iocHtions on the motherboard. RAM chips that are generally available. 6502 PHASE2 PHASED COLUMN RAS' CAS' Q3 6502 wtite data valid on data bus before during CAS' falls PHASED. Figure 5.1 RAM Timing Signals. RAM and Memory Management 5-3 Dynamic RAM must be periodically refreshed The RAM connections support the demands of for it to operate properly. The refresh requirement MPU read/write access to motherboard or auxiliary of 64K chips is that each of the 256 possible ROW card RAM, alternating with simultaneous video addresses must be accessed every two milliseconds, scanner read access to both motherboard and auxil- or 500 times a second.* This can be acconrplished in iary card RAM. During PHASE 1, the video scanner RAS'/CAS' cycles or in RAS'-only cycles. It is drives display data from motherboard RAM to the accomplished in RAS'/CAS' cycles during PHASE data bus and from auxiliary card RAM to the auxil- 1 in the Apple lie. The refresh requirement in the iary card RAM data bus. This video data is saved in Apple is met in the process of scanning RAM for the motherboard and auxiliary card video data video output. latches when PHASE 0 rises. During PHASE 0, the MPU reads or writes to motherboard RAM or auxil- RAM CONNECTIONS IN THE APPLE Me iary card RAM or another Apple device. Data transfer to or from the MPU occurs shortly after The general flow of RAM data was discussed in PHASE 0 falling when the 6502 PHASE 2 clock Chapter 2. Figure 2.7, the bus structure diagram, falls. should be reviewed to reinforce in your mind how The RAM access scheme is complex, but the RAM is tied into the overall scheme of things in the hardware implementation is compact. The critical Apple. The basic features of RAM connections in the control elements are the CASEN' and EN80' sig- Apple are: nals from the MMU, the read/write control and 1. Motherboard RAM and auxiliary card RAM CAS'inputstothe RAM chips, and theenable/isolate areeach made upofeight64K RAM chips. Each input to the auxiliary card data bus driver. RAM chip is associated with one line of the data The motherboard RAM R/W' signal is not the bus, and eight chips are capable of storing same as system R/W from the 6502— it is system 65,536 bytes of data. R/W' gated by PHASE 1 low (PHASE 0 high). The 2. Motherboard RAM data input and output are 6502 R/W line drops low some time during PHASE 1 of write cycles. This would interfere with video tied directly to the data bus for MPU writing, MPU reading, and latching in the motherboard scanner reading if 6502 R/W' were connected di- video latch. rectly toRAM. Another way of looking at this is that the video scanner controls the motherboard RAM 3. Auxiliary card RAM data input and output are address and RAM R/W during PHASE 1. The connected to the auxiliary card video latch and video scanner always reads, never writes. through a bidirectional driver to the data bus. The bidirectional driver isolates auxiliary card CAS' from the timing HAL is connected to the RAM from the data bus any time the M PU is not motherboard RAM CAS' input (RAM pin 15), and writing to or reading from auxiliary card RAM. RAM chip operation is such that when CAS' falls 4. The latched video data is routed to the video after RAS', data is passed in or out depending on generator for processing. RAM R/W'. As a result, motherboard RAM com- municates with the MPU when the MMU brings 5. The RAM address input is multiplexed among the address bus ROW address (MMU), address CASEN' low, and consequently allows CAS' to fall bus COLUMN address (MMU), video scanner during PHASE 0. The MMU brings CASEN' low ROW address (lOU), and video scanner COL- when the MPU accesses an address that is config- UMN address (lOU). ured in the MMU for motherboard RAM response. CAS' always falls during PHASE 1. so video data is Figure 5.2 is a schematic diagram showing the always passed from motherboard RAM to the data connections of motherboard RAM, auxiliary card bus during PHASE 1. RAM, and the associated video data latches. The Auxiliary card RAM communication with the RAM chips are connected together in a way that MPU is controlled differently than motherboard reminds you of the wiring of the peripheral slots. RAM communication. Q3 is tied to the auxiliary Ihe majority of the RAM lines are just strung from card RAM chip CAS' input, and Q3 always falls chip tochip. This includes the address input (RAO- during PHASE 0 and PHASE 1. Therefore, auxil- RAT). +5V, ground, RAS'. CAS' and RAM R/W' iary card RAM chips pass data in or out twice every (motherboard), and Q3 and R/W'80 (auxiliary card). MPU cycle. The RAM chip data, however, is iso- lated from the motherboard data bus by the 74LS245 'Some manufacturer's 64K RAM chips havea 12S-cycle require- ment tfiat iseasier to meet. The Apple He meets both the 128- and bidirectional driver unless EN80' from the MMU is me di66^^ycIe refresh requirements. low. Operation of the LS245 is such that when its ' '^ i Bo-- 54 Understanding the Apple lie DATA BUS (3.9) RP2 ho IK > (4 2) \y^ LS125 ^ EXTENDED 80-COLUMN CARD (64K AUXILIARY RAM CARD) Figure S 2 Schematic: Apple Ile RAM Connections. RAM and Memory Management 5-5 enable input (EN80') is high, the driver presents a auxiliary card display maps are processed. Also, high impedance to both the motherboard data bus VID7M variations are such that video dot patterns and the auxiliary card RAM data bus. EN80' is are shifted out twice as fast in DOUBLE-RES and never low during PHASE 1, and it goes low during LORES40 processing as they are in TEXT40 and PHASE 0 only when the MPU is accessing an HIRES40 processing, address that is configured in the MMU for auxiliary A point about Figure 5.2 which the reader may card RAM response. find confusing is the labeling of the multiplexed The direction control input of the LS245 driver is RAM address bus and the address inputs to the R/W', so direction of the driver is correct when the RAM chips. RAO of the bus goes to A7 of the RAM MPU communicates with auxiliary card RAM. The chip; RAl of the bus goes to A6of the RAM chip; etc. read/write control of the RAM chips is R/W'80, Shouldn't RAOgo to AOof the RAM chip? Weil, that which is the same as R/W except that it can only go would have been logical , but it's not very important. low when EN80' is low. Therefore, the MPU writes Generally, the address-line labels on a RAM chip to auxiliary card RAM when EN80' islowand R/W are arbitrary and have no operational significance.* is low. Since EN80' is PHASE 0 gated, the video The RAM works as longas each address bit is routed scanner access to auxiliary card RAM is always a to one of the address inputs. In this case, the RAM read access, just as it is with motherboard RAM. chip labeling provided a natural reference for label- There are some subtle but important points about ing the RAM address bus and the RAM address the handling of RAM output in the Apple. The data output pins of the lOU and MMU. For reasons bus is available at the end of PHASE 1 because the unknown, Apple did not use this natural reference. MPU never controls the data bus at this time, not even during write cycles. The MPU controls the RAM ADDRESS MULTIPLEXING data bus for the second half of PHASE Oand slightly beyond during write cycles. But nothing in a write Portions of both the lOU and MMU are devoted to cycle prevents the video scanner from reading RAM address multiplexing. Together, these muii- RAM, and nothing prevents the RAM output from plexing circuits make up a 4 to 1 RAM address being latched for processing in the video generator. multiplexor. The MMU develops the MPU ROW Therefore, write cycles do not cause random flicker and COLUMN address from the address bus, and the lOU develops the video ROW and COLUMN in the Apple's video display. Another interesting point is that data from the address from the video scanner state and the Apple videoscanner access to motherboard RAM is always display mode. available on the data bus when PHASED rises. This RAM address multiplexing functions are sum- video data is also passed through the peripheral slot marized inFigure 5.3. In both the MMU and the bidirectional driver to the peripheral slots when lOU, RAS' high selects the ROW address input, and R/W is high or for a very short period after the RAS' low selects the COLUMN address input. The beginning of PHASE 0 when R/W is low. This MMU multiplexed address is gated to the RAM means that motherboard video data can be read by address bus during the last 14M period of PHASE 1 peripheral cards, and many conceivable peripheral and the first four 14M periods of PHASE 0. The designs could make use of this data. A program- lOU multiplexed address is gated to the RAM mable video scanner simulator is one such design. address bus during the last 14M period of PHASE 0 In SINGLE-RES or DOUBLE-RES display and the first four 14M periods of PHASE 1. This mode, latched auxiliary card RAM data is available gating ensures that, after propagation delay, the on the video data bus during PHASE 0, and latched MPU address is valid at the RAM chips when RAS', motherboard RAM data is available on the video CAS', and Q3 fall during PHASE 0, and the video databusduring PHASE 1, It is in the timing gener- scanner address is valid at the RAM chips when ator, not RAM, that SINGLE-RES and DOUBLE- RAS', CAS', and Q3 fall during PHASE I. RES processing are different from each other. In MMU multiplexing functions are a straightfor- SINGLE-RES processing, no LDPS' pulse is gener- ward translation of the 16-bit MPU address into ated during PHASE 0 to load the auxiliary video 8-bit ROW and COLUMN addresses. The only com- data into the video generator, so only the mother- plication isthat the A12 input to RA4-C0L is forced board display map is processed. In DOUBLE-RES *An exception is systems in which oniy AO— A6 of tiie 64K chip processing. LDPS' is generated during both PHASE are refreshed. AO— A7 of the RAM chips in the Apple He are » and PHASE 1, and both the motherboard and refreshed, so this has no significance in the Apple lie. m,'K:m& ^=1 5-6 Understanding the Apple He r« \i ' ^ ""x < i ss It y 1 ? o ir to ■ffii■ 1 i3 =)o ^ ?^ 2 p ass i^ l^,z zS S *£ UJ UJ 00 '^iJ IS X 1 1 Crt c/> i Qu UJ cc f^ < < Ul o > > CO o to o < [=1 o ( =3 (/5 Z3 CO \ , < \ <: ■* ^< DC (3 LJJ •<* CD o < oj - -iC 5- ? s \ n Fnr — ;z J ^ s^ r rq s^ ^-?° n< 0 i: "^i ^ 5 t* □ c ]MM Oi ^ > ' c ^ /* ) a* r oriW 1[ si i y*\ jJv y^ ^ Z i> y^OVfDQ m ^ 1 —^i^ T 1 f s.1 JOflESS DECODI SW(7 ITCHES in CES SW{5 ITCH 1 [ l- 1 L g 1- CANN(3. ER8) + BUS i4,2) =i 3FT rt< T .It ?, 5 ?, -q- LTI (£! 1H II ^g§ Crt IS gsSsEa :^ 1 f2

■! >l si (391 5 SS a ss I £5II S^II i^ TT ?5 Jf '^5«lSF.'f^ RAM and Memory Management 5-7 low if an address in the $DXXX range is on the DOUBLE-RES graphics. This, though, is not the address bus and the BANKl soft switch is set. Forc- case. By resetting 80STORE and setting PAGE2, a ing A12 low changes $DXXX to $CXXX, and al lows programmer can select the $800— $BFF area for the MPU to access the bank 1 area of high RAM. TEXT/LORES display or the $4000— $5FFF area lOU multiplexing functions are more complex for HIRES display, even in the DOUBLE-RES than those of the MMU. This is because .the video modes. Furthermore, if 80ST0RE is set, the second- RAM address is not simply a multiplexed form of ary pages cannot be displayed. the video scanner outputs. Instead, it is a combina- The RAM address inputs are selected from the tion ofthe Apple display mode and the video scanner address bus, the video scanner state, and the dis- output with special offset logic to facilitate the scan- play mode. The MULTIPLEXED RAM ADDRESS ning of the Apple's unnatural 40-byte display line table in Figure 5.3 shows the way address bus width. The display mode, which is set up via lOU lines and video scanner output lines are assigned soft switches, is an extension of the video scanner to RA0-RA7 ROW and RA0-RA7 COLUMN. when it comes to addressing RAM. Generally, the There are some significant aspects to these address display mode controls the high order address bits, assignments: thus determining what areas of RAM the video scanner accesses. 1 . The scanner low order bits are assigned to RAM The HIRES TIME signal which is used in RAM ROW address inputs so the RAM will be re- freshed bythe video scanner. addressing is a product of the video scanner state 2. Theaddressbusbit whichcontrolsagiven RAM and the lOU display mode control soft switches. address will be equivalent to the scanner bit HIRES TIME is high when the Apple is in which controls the same RAM address. For HIRES-GRAPHICS-NO MIX mode, or in HIRES- example, AO controls RAO during an MPU GRAPHICS-MIX mode when V4 • V2 is false. The ROW access, and HO controls RAO during a V4 • V2 gating switches the scanned memory over to scanner ROW access. This means that AO and TEXT memory for four lines of text at the bottom of HO perform the equivalent RAM addressing the screen. Naturally, the MIXED mode requires function. switching between GRAPHICS and TEXT in sync with the video scanner. 3. The address bus low order bits are assigned to RAM ROW address inputs for correct equiva- The PAGE2 and 80STORE inputs to Figure 5.3 lency toscanner addressing bits. It happens that are lOU soft switches. When set, PAGE2 selects this assignment results in AO— A5 and A7 being secondary display memory pages for scanning. available to the lOU as part of the MMU ROW 80STORE, when set, overrides the effect of PAGE2 address. The only other address input the lOU on memory scanning, thus inhibiting display of needs is A6, and A6is inputdirectly to thelOU screen page 2. The 80STORE, PAGE2, and HIRES from the address bus. soft switches are also implemented in the MMU 4. The addressing of RAM is the same in DOUB- where they are used for swi tch ing between access to LE-RES asit is in SINGLE-RES display modes. motherboard and auxiliary card RAM. It should be noted that the Apple II Reference Table 5.1 shows the equivalent address bus/ video Manual/or He Only sa.ysthsLtmYm,mt80STORE, scanner address bits. You can use this table to take is the soft switch which affects RAM addressing. any screen mode and video scanner state and con- This is an area in which the reference manual vert them to an equivalent MPU address. If you IS inconsistent, using the terms 80STORE, 80VID, store a byte of data at the equivalent MPU address, and 80COL to refer to what are, in fact, only it will be driven out of RAM during PHASE 1 when two soft switches (W$COO0/W$CO01 and W$COOC/ the video scanner reaches the chosen state. W$CO0D). Tb avoid confusion, I suggest you change The Arithmetic of Video Scanner oOyiD to 80COL throughout Apple's reference man- Memory Addressing omr^" pages 3 and 4 of Apple's schematic, change 80VID' at pin 6 of the lOU and pin 25 of the auxil- If the Apple isn't famous for the encrypted nature iary slot o 80COL'. of its screen memory addressing, it should be. The "The soft switch that overrides PAGE2 in the programmer has a very heavy burden in computing ™.J^ SfSTORE (W$COOO/W$C001), not 80COL or looking up seemingly illogical addresses. This (W$CO0C/W$CO0D). The operational difference is goes all the way back to the original design of the fh***" J^ 80COL was the RAM addressing input, Apple 11, since Apple lie display memory addresses tien there would be only one displayable page of are the same as those of the older computer. '^'fef e 5-8 Understanding the Apple He Tabte 5.1 MPU/Scanner Equivolent Address Bits. MPU VIDEO SCANNER AO HO Al HI H2 A2 A3 SUM-A3 A4 A5 vo SUM-A4 SUM-A5 Af> SUM-A6 A7 A8 A9 VI V2 AH) HIRES . VA TEXT/LORES • (PAGE2 • 80STORE')' All HIRES • VB TEXT/LORES • PAGE2 • 80STORE' A12 HIRES. VC — Ai;^ HIRES •{I'AGE2.80STORE')' ~ AM HIRES . rA(;E2 . 80STORE' - A15 —- Thero is log'if to the Apple screen memory ad- a little hardware complexity. Instead of using 40 dres ing. Itis the logic of binary manipulation. The bytes out of each 64-byte memory segment, 120 waj' to understand it is to look at the Apple from the bytes out of each 128-byte memory segment are desijrner's \iewpoint. In 1975, how would you have used, Thiscreateseightbytesofwastedmemory for jfotten the Apple to display HIRES color graphics, every three horizontal scans in HIRES or every IjORF^S color graphics, and 40 columns of text? three I ines of characters in TEXT. As a result, there F'orty colunnns? Two strikes against you to start is a total wastage of 512 bytes in HIRES and 64 with. Didn't Wozniak ever hear of powers of two'.' bytes in TEXT/LORES. Digital computers are based in binary numbers. How do you implement this in hardware? Screen Use '.V2, (54, or 1 28 columns. This is as bad as the guys memory is divided into 128-byte segments (see who desig:ned 80-eohimn typewritten page widths Figure 5.4). Each segment isdivided into the FIRST and 10-digit humans. 40, the SECOND 40, the THIRD 40, and eight The problem is that you want to address memory bytes of no man's memory (UNUSED 8). It so seciuentially with the output lines of the video happens that the displayed television scan is neatly scanner. If the Apple line width had been 32 divided into three sections by V3 and V4 from the columns, you couid .just tie HO— H5 and VO— V4 video scanner as follows: directly to a 4 to 1 address multiplexor. Memory would be very neatly divided up into 32 x 24 bytes. V4' V3' —Top third of television screen Upgrading the display from 32 to 40 columns V4' V3 —Middle third of television screen makes the scanner address assignments less V4 V3' —Bottom third of television screen V4 V3 -Undisplayed(VBL) straightforward. You can achieve a 40-co!umn dis- play by tying HO— H5 directly to the 4 to 1 address Because the three displayed portions of the screen multiplexor, and this would create an easy hard- can be so easily detected, they are mapped into the ware connection. But there would be unused gaps in three Top 40-byte sections of each 128-byte memory memory 24 bytes long for every 40 bytes used. This segment as follows: would waste 576 bytes of memory in TEXT/LORES LOCATION modes and 4608 bytes in HIRES mode. What good ON TV are 4608 bytes of memory divided up into 192 non- SCREEN LEAST SIGNIFICANT contiguous groups of 24 bytes? BITS OF ADDRESS In the Apple, it was accepted that there would be Middle 0000000 OlOOllKFIRST 40) some waste of memory caused by the 40-character Bottom 0101000-1001111 (SECOND 40) lines, but the waste was minimized at the expense of 1010000-1110111 (THIRD 40) RAM and Memory Management 5-9 128 BVTE MEMORY SEGMENTS /\ FIRST 40 40-79 0-39 SECOND 40 THIRD 40 80 - 1 19 Figure 54 128-Byte Video Memory Segments Consist of Three 40-Byte Sections, Each Mapped Into a Different Part of the Video Screen. V3 It can be seen in the biTiary representations of the H5 H4 H3 40-byte address sections, that the lower three bits V4 V4 V3 cross over from 111 to 000 at ali section boundaries. SUM-A6 SUM-A5 SUM-A4 SUM-A3 This means that these three bits can be identically This would create the three offsets 0, 101, and 1010, addressed in the FIRST 40, SECOND 40, or THIRD 40. For example, the lowest three bitsof the address which are 40-byte offsets. This circuit would work, of the left most character in any section is 000. For but it would make screen memory address assign- this reason, HO, Hi, and H2 are direct address ments even more complex than they are for the inputs to the lOU address multiplexor and are Apple programmer. Since the display starts at H5- address equivalents of AG, Al, and A2. H4-H;-! = Oil, we need to subtract Oil from the offsets 000, 101, and 1010 to make the FIRST 40 The next four address bits are different depend- ing on the 40-byte section that is being addressed. start at a natural 128-byte segment boundary. The They are 0000 through 0100 in the FIRST 40, 0101 required offsets are 1101,010, and 111 (-3, 2. and 7 through 1001 in the SECOND 40, and 1010 through indecimal). You need to address A6-A5-A4-A3 with 1110 in the THIRD 40. These four bits are addressed the values H5-H4-H3 minus Oil in the FIRST 40. H5-H4-H3 plus 010 in the SECOND 40, and H5-H4- by H5-H4-H3 plus an offset. The offset value is selected by V4 and V3 to place the scanned memory H3 plus 1 1 1 in the THIRD 40. These sums are clev- address in the FIRST 40, SECOND 40, or THIRD erly created in the Apple by the following addition: 40 of the current 128-byte segment. The offset is 1 added to H5-H4-H3 in a 4-bit adder in the lOU, and H3 the four bits of the resulting SUM become the scan- V3 V4 H4 V3 ning address bits equivalent to A3, A4, A5, and A6. SUM-A6 SUM-A5 SUM-A4 SUM-A3 This book refers to the SUM bits as SUM-A3, SUM- V4 A4, SUM-A5, and SUM-A6. H5'-H5'-H4-H3 is equal to H5-H4-H3 minus 100 in There are eight states of H5-H4-H3 but only five 4-bit signed binary arithmetic. 001 minus 100 is of the states are displayed. 000 through 010 are —Oil, so the needed offset is developed. It is easy to undisplayed and occur during the right margin, add 1 as a carry input to the 4-bit adder. The equiva- horizontal retrace, and left margin of the television lent adding circuit is: scan, on is the first displayed count, and when H5- H5' 1 0 1 H5 H5' H4 H3 H4-H3 reaches Oil, it is time to address the first byte of a 40-byte section. Suppose you built the fol- V4 V3 V4 lowing summing circuit: SUM-A6 SUM-AS SUM-A4 SUM-A3 V3 MO UfxterjtandlngmeAppteUe memory output on the data bu.s or peripheral data TEXT/LOWS Scanning bus. This is possible in software by reading an address from which there is no data response. For B«yond Aft, ftcanninK afldrcws a»»ijfnmente deter- mine the memory blfjckn m&nne<\ in the variffus example, if you zero out al 1 scanned memory except icreen mixlm. VO, V 1, and V2 are equivalent to A7, for the bytes in the blanking period preceding a AH, and AH in all (wreen mfxJe», A TEXT/LORES ^iven horizontal display line, you can detect the »t<;reen memf»ry pajc« i« mafk up of eij?ht afJjacent beginning of that horizontal scan with the following Iwjp. 12H-hyUt MfjfmfrntH. Tbfjw; ffJKht a^Jjacent Hejrments art; fififinef] by VO, V 1 , and V2 in thf; scanner and by PAGEl EQU $C054 A 7, AH.and AtJon thf^addrtiKH bun. VA, VB.and VC WAIT LDA PAGEl play noimrtin addrf.'HHinjf TKXT/LORES memo ry. BPL WAIT Rather, the Hame 40-hyte section of memory is M(!ann*;d for citfht adjarrnnt horixontal television Some techniques of exploiting this capability are lint'M. It ihko-H ciffht horizontal K'loviwion lines to discussed in an application note at the end of this paint oni; lincof U;xtor two rowHof I/)RES hlocks. chapter. The point is that it is sometimes useful to In videoKoncrationcircijilHinU'rnai and external to know what areas of memory are being scanned the ion, VA, VM.and VC define which vertical part during blanking periods. of Hl4'xtrhnracl2.ThisreHultsinthe horizontal display period isshown directly to the left memory Hcarincdsirctw for TKXT/IiJ RES shown at of the memory scanned during that display period. the l«)tl^)m rif thiH piiffc. The vertical blanking period is shown at the bottom. FiKurc Tj.f) \h the TKXT/LOKES displayed mem- The considerations which determine the memory ory mafi. This map shows the same information as scanned during the blanking periods are as follows: the nni]M of the A/jjilr II lii'firt'ncc Miinual for lie INT(BASE/128) In addition to th<' displayed memory locations, THEN HBL = HBL+128 there is reason lo know what areas of memory are hein^ scann(>d while nothing is being displayed. Step 20 of the above program is necessary Thisblankingtimeisdefined by horizontal and ver- because horizontal memory addressing wraps tical bliinking gates generated in the lOU from around at the 128-byte segment boundaries. video scanner outputs. HBL (Horizontal BLanking 2. The first address of HBL is always addressed gate) is high during the right margin, horizontal twice consecutively, because HO— H5 is in the retrace, and left margin of the Apple video display. all zero state for two consecutive scans. VBL (Vertical BLanking gate) is high during the ;?. During VBL(vertical blanking), V3 and V4 are bottom margin, vertical retrace, and top margin of both true. The horizontal offset sum becomes the Apple video display. H5-H4-H3 minus 0100. This is almost the same Knowledge of memory scanned during HBL and VBL has applicationa v/hen software or hardware as the top of the displayed screen (H5-H4-H3 minus OOll). The VBLbase addresses are equal iync8 to the video scan by detecting the scanned to the FIRST 40 base addresses minus eight SCRXEH MODE BINARY p;vaE 1 0000 01XX XXXX XXXX HEXADECIMAL PAGE 2, eeSTORE 0000 01XX XXXX XXXX 0000 10XX XXXX XXXX §0400-$07FF PAGE 2, 80STORE' §0400-$07FF ?0a00-$0BFF &'■' RAM and Memory Management 5-1 1 TOP SCREEN/ MIDDLE SCREEN/ BOTTOM SCREEN/ BASE FIRST 40 LIN# SECOND 40 LIN# THIRD 40 LIN# RANGE RANGE UNUSED 8 ADDRESS RANGE RANGE 00 $400-$427 08 $428-$44F 16 $450-$477 $400 1024-1063 1064-1103 $478-$47F 1024 1104-1143 1144-1151 $480 $480-$4A7 09 $4A8-$4CF 17 $4D0-$4F7 1152 1152-1191 1192-1231 $4F8-$4FF 01 1232-1271 1272-1279 $500 02 $500-$527 10 $528-$54F 18 1280 03 1280-1319 1320-1359 $550-$577 $578-$57F 1400-1407 20 1360-1399 $580 $580-$5A7 11 $5A8-$5CF 19 $5D0-S5F7 PAGE 1 1408 1448-1487 $5P8-$5FF 1408-1447 1488-1527 1528-1535 $600 04 $600-$627 12 $628-$64F $650-$677 1536 1536-1575 1576-1615 21 1616-1655 S678-$67F 05 1656-1663 $680 $680-$6A7 13 $6A8-S5CF $6D0-$6F7 1664 1664-1703 1704-1743 1744-1783 $6F8-$6FF 1784-1791 $700 06 $700-$727 14 $728-$74F 22 $750-3777 $778-$77F 1792 1792-1831 1832-1871 1872-1911 1912-1919 $780 07 $780-$7A7 15 $7Aa-S7CF 23 $7F8-$7FF 1920 $7D0-$7F7 1920-1959 1960-1999 2000-2039 2040-2047 $800 00 $800-$827 08 $828-$84F 16 S850-$877 $878-$87F 2048 2048-2087 2088-2127 2128-2167 2168-2175 $880 01 S880-$8A7 $8A8-$8CF 17 $8D0-$8F7 $8F8-S8FF 2176 2176-2215 2216-2255 2256-2295 2296-2303 $900 02 $900-S927 10 09 $928-$94F 18 $978-S97F $950-$977 2424-2431 2304 2304-2343 2344-2383 20 2384-2423 $980 03 $980-$9A7 11 $9A8-$9CF 19 S9D0-$9F7 $9F8-$9FF PAGE 2 2432 2432-2471 2472-2511 2512-2551 2552-2559 $A00 04 $A00-$A27 12 $A28-$A4F 2560 05 $A50-$A77 $A78-SA7F 2560-2599 2600-2639 2640-2679 2680-2687 $A80 SA80-$AA7 13 $AA8-$ACF 21 SAF8-SAFF 2688 $AD0-$AF7 06 2688-2727 2728-2767 2768-2807 2308-2815 $B00 $B00-$B27 14 SB28-$B4F 22 $B78-$B7F 2816 2816-2855 23 $B50-$B77 2896-2935 2936-2943 2856-2895 $B80 07 $B80-$BA7 15 SBA8-$BCF SBD0-$BF7 $BF8-$BFF 2944 3064-3071 2944-2983 2984-3023 3024-3063 Figure 55 TEXT/ LORES Displayed Memory Map. bytes using 128-byte wraparound subtraction. PAGE2 • 80STORE'. This results in a page 1 base Example: $400 minus $8 gives $478, not $3F8. add ress of $2000 and a page 2 base ad d ress of $4000. 4. Horizontal scanning wraps around at the 128- The effect of 80STORE, as in TEXT/LORES scan- byte segment boundaries. Example: tlie address ning, isto override the PAGE2 soft switch. scanned before address $400 is $47F. VA, VB, and VC are equivalent to AlO, All, and A12 in HIRES, This is the most important point, HIRES Scanning because it represents the great difference between Uble 5.1 shows that HIRES video scanner ad- HIRES and TEXT/LORES. In TEXT/LORES, 40 dres ing isdentical to TEXT/LORES addressing bytes contain the display intelligence for eight on bits A0-A9 and A15. The differences in bits horizontal scans. In HIRES, 40 bytes contain the AlO— A14 reflect the facts that HIRES memory is display intelligence for one horizontal scan. The eight times as big as TEXT/LORES memory, and in HIRES scan must address a different 40-byte sec- a different location than TEXT/LORES memory. tion every scan. This is accomplished by letting VA, /DA '"^ HIRES scanning, A13 is equivalent to VB, and VC affect the memory address in HIRES {i'A.GEZ . 80STORE')', and A14 is equivalent to scanning. r^m 5-12 Understanding the Apple lie One viray to gain insight into the overall layout of Notice in Tkble 5.1 the oddity that VA, VB, and HIRES memory is to run the following BASIC VC address higher order bits of memory than do VO, VI, and V2. This causes the base addresses of adja- program: cent HIRES lines to be separated by 1024 bytes, 10 HGR : POKE -16302,0 ; rather than the logical 128 bytes. This extra com pli- POKE -16372,0 NOMIX : REM HIRES40, cation of HIRES address computation could have been eliminated in the original Apple II design by 20 FOR A = 8192 TO 16383 the addition of onechip.lt wasn't, so the user suffers 30 POKE A, 255 an extra operational distraction in the Apple II and 40 FOR B = 0 TO 100 : NEXT B s the He. One way to look at the HIRES memory REM DO IT SLOWLY layout is as eight adjacent areas with each area the 50 NEXT A : GO TO 10 memory equivalent of a single TEXT/LORES page (see Figure 5.7). VA, VB, and VC determine which This program fills the consecutive memory loca- of the eight areas is being addressed. As eight adja- tions ofHIRES, PAGE 1 with $FFslowly so that you cent horizontal lines are scanned, one 64-byte (40 can watch the screen fill. bytes displayed) section from each of the eight Figure 5.8 is a HIRES displayed memory map memory areas is scanned. As in TEXT/LORES, the accenting the division of screen memory into 128- top, middle, and bottom thirds of the screen are byte memory segments. This figure was printed out accompaniedby memory scanning of the FIRST 40, using an Applesoft program listed in Appendix D. SECOND 40, and THIRD 40 sections respectively. Like the TEXT/LORES map of Figure 5.5. this tDRIZOHTAL BLANKING (HBL) HSRIZCtrrAL DlSFLXi ENhBL£ iimiu " S400 1024 111111111111111122222222 MUM PACE 1 PAGE 2 001 23456789ABCDEroi234567 PAGE 1 PAGE 2 01234 567a9ABC[^Fgl234567a9AaCEeF01234567 I I I I I I lt**#l I I M I I I M I I I M I MUn M HI MH I IH m I I I I I I I I M II S«8 1128 S868 2152 $800 2048 $4B8 1256 SBEB 2280 I I I I n <####! I M I I I M M IIIIII II IIIIIIM M M IM IM I S568 1384 MINI l####l I I I I I I I I I I 5480 1152 5380 2176 I M I I I i 1 I I I I I I H 1 n U I 1 I I M II iMimttt.* m I H H 114 S968 2408 5500 1280 5900 2304 SCREEH S5ES 1512 ?9E8 2536 hf-1 t f !■>#### M I M I M M t-k I MMMI IIII 5580 1403 59B0 2432 l-t M HH ht n+n M M I I I M I I I I ► niHI in I I TCiP 5668 1643 5A68 2664 I I I M I itlft#\ n I I I I I I I I I I I I I ll«#«tH I I I I I I I I I 5600 1536 5A00 2560 IIIIIM I IIIItI IIM M IIIIH I I mill 11111 S6E8 1758 SAES 2792 5680 1664 $AJ90 2688 S768 1896 SB68 2920 HI H-fr >#»##! M I M I H M I SB00 2816 111111H u H M n H IH n n M 5700 1792 IIIII1 II IIIH M I< IIIIM IH > tI Mmill Mt t444|.t I Mil 57E8 2024 5EE8 3043 n I M I l####l I I I I I I M I I SBSa 2944 5780 1920 2064 Mill il#)>##H I M I I I I I I 1064 2088 H I I I M I I I I I I H I I I H I I I I I I I IHMimH I 5410 1040 5490 1168 5810 2192 I t M t I l####l I I I M I I I M 1192 2216 t I ft »t4fH-l-t l-f M M H HM HM t-Htl I I I I I I I I 5890 S510 1296 2320 1320 2344 I I I I I I I I I I I I I I n I I I I I II I II I I mm I III I S910 2448 i-m-«+f###- 5428 S4A8 5829 2472 I I I I I > I 1 I I I H M I > I I I M M I I > SCREES $59B 1424 1448 MIDDLE S610 1552 5990 2576 1 1 1 1 1 ii«#t«n 1 1 1 1 1 1 1 1 1 5528 5aAS 2600 1576 2728 IIIIIIIIIII ♦ mm I mi I III I II I mi 5690 1680 2704 >.n>tt<#tnn n 1 1 1 1 1 1 1 1 592S 2856 I I M I > I H I I'H H-H M't 1444 Hi Mn n 1 1 mi 1704 5A10 S710 1808 5A90 2832 I II I M l#fr*#l I I I I I I I I I I S5Aa 59A8 1832 I I I I I I I I M I I I I M M N I I I I I I I 1 1 1 mmn4 5628 2984 5790 1936 5B10 2960 1 1 1 1 M i####i n 1 1 1 1 1 1 1 I 56AS 1960 IIIM M IIIIIIIIIIIIIIIIIIM 1 1 1 1 1 1 1 1 1 II I 5AAB 5B90 5436 1080 SB39 2104 #***in 1 1 1 1 1 1 1 1 5728 5450 1104 5A2B 5H28 2128 I I I I I I 1 1 I I I I I I H > I H I I I 1 1 I > 2232 «t»#4 $7AB 5BAB 2256 4-1 til H 14 I I H MM4 H I M H4>' I I I I I I I mi > 54B8 120B 5400 1232 S538 5838 2360 1336 5938 2466 1 1 i 1 1 I i*«t«iH I n 1 1 H++ 5800 2512 4 1 iHHH 1 1 n H m n I m 1^4 >■ I I M III I ml SCREE» 5550 1360 444Htl H«l I 55B8 1464 5988 **l I444tt«« I 1 ! I I I I I M I S5D0 1488 5850 2384 I I I M M I I I I I I I ( I M M I I I I I I > BOTTOM 5638 1592 2616 2640 I I I I I I 1 I I I I I I I H H M I H I I I I I I II I I I I I III t«t»'lt 5650 1616 2768 I I I I I I I I ml 5668 1720 SRB8 2744 II #tt#m I II 1 1 1 II I 5600 1744 5950 2896 I I I H I 4 I I I I I I M I M I I I I I I I M 5A38 4111111 I Ht4 5738 1848 2B72 1 1 1 1 llttttll 1 1 1 1 1 1 1 1 1 5750 1672 59D0 IIIH H II IIIIIIIM M IIIIIII 5768 1976 $E38 3000 5A50 57DC 2000 5AD0 3024 4- mi > I I I I I I I I I I > I I I I I I I I M t n 1 1 1 1 1 1114 5BB8 5HD0 mimi iiu 5460 1120 5860 2144 1 1 1 1 1 iitttttn I n 1 1 1 1 5478 U44 5B50 I I I I I I II 14 H I I I I I I I 5878 2168 $4Ea 1248 SeiB 2272 -++++++####++++44444+4 2296 I I I I I > I I I I I H M I I I 141 I H m 54FB 1272 53F6 I H I I 11 I llll 5560 1376 5960 2400 ++++-+++####++++444444+ +4H I !)#### 5578 1400 S97S 2424 +4-1 4 M I I 4 I I I I I M I I M I I I I I M II Kill VEBTICAL 55B0 1504 S9E0 2528 55FB 1528 BLANKINC +4+44+4############|#it 59re 2552 + IHH I 11 M M I4H H4I in HI I Mimi H>> 5660 1632 SA60 2656 5678 1656 5A76 2680 M#«#*t«t«tt«*t###ft*«t*»i**tt*HHt»#t. 56E0 1760 5AE0 2784 tfl Ml H##tl I I I II I I I 141- 56F8 1784 4 I I I I 11 14 I I II H Ml 11 I I >l I M mm 5760 1888 5B60 2912 +++-l-l-++#### I I I I I I 5778 1912 5AF8 2808 5B7a 2936 I I I I I M I I I I I I I I I I I I M I I I I I 1 1 11 m m-i-f T H>+ «*♦« 1-1414 T 57EB 2016 5BEB 3040 5BFB 3064 I I I I I M 14 I tH 1444 4 I I I I II IM 57CS 2040 Ibe last rcw of menory ia scanned 14 HORIZOmAL SYNC oonseeutive tintea. All oUier rows ore scanned a oonaecutive times. voniCAL sac Rgure 5 A TEXT/LORES Scanning Map Including Undiq»layed Areas. ..fti« RAM and Memory Management 5-13 128 BYTES re-vB-vA C ^ s J2000 000 \\/ V/ ' 001 $2400 A ^ 9 £2800 010 {2cao 011 t n 1 ►- B $3000 100 S340O 101 $3800 110 S3C00 111 J Figure 5 .7 HIRES Memory Areas (Page 1 ). ml ^'^^^ ^ different perspective for viewing third of the screen minus eight bytes. Memory IIRES memory usage. Figure 5.9 is the full HIRES scanned by lines 256 through 261 is identical to lemory map showing addresses scanned during memory scanned by lines 250 through 255, so those BL and VBL, as well as the displayed map. It was six 64-byte sections are scanned twice, as shown in isomadebyan Applesoft program listed in Appen- Figure 5.9. The memory scanning areas are sum- IX U, For reference, "#" is used in Figure 5.9 to marized inT^ble 5.2. This same information is dis- WW when horizontal or vertical television sync is played graphically in Figure 5.17. "put from the lOU. The #s in the middle of every oL period represent the horizontal sync which Mixed Mode Scanning wses the horizontal retrace. The long strings of HIRES graphics mixed with TEXT is a special #s '""es 224— 227 represent the vertical sync which case when it comes to video scanner addressing. tuses the vertical retrace (60 Hz lOU). Please note Part of HIRES memory and part of TEXT/LORES f J™y"c in the Apple lie is identical to that of memory must be scanned in this mode. The problem e KM Revision Apple II, so the sync does not arise with LORES graphics mixed with rPicted in Figures 5.6 and 5.9 is validgeneration for both TEXT, because TEXT memory scanning is identi- iiputers. cal to LORES memory scanning. The scanning during blanking periods in HIRE The HIRESTIME term that isusedtodevelop the S ve)7 similar to that in TEXT/LORES. The video scan address is not a direct input from the mem- Mocations scanned during HBL prior $C056/$C057 LORES/HIRES soft switch. Rather, to a dis- lyed hneare the 24 bytes just below the it is a term developed in the lOU which is active displ a, using 128-byte wraparound addressing ayed . The when it is actually time to scan HIRES display * scanned during VBL is the same memory. In HIRES MIXED mode, the HIRES as the top ">-i!Lir.'' ~~ ■ "~^ ■14 Understanding the Apple lie '— lira BOTTOM SCREEM/ UNUSED e TOP SCREEN/ FIRST 40 MIDDLE SCREEN/ LIN# SKCOND 40 LIN# THIRD 40 PAGE 1 RANGE -^$2i §^-!B4^~$2^: 47T PAGE 1 PAGE 2 LIN# PAGE 1 RANGE PAGE 1 RANGE 064 128 52050-52077 52878-S2B7F 52000 8192 16384 52000-32027 S2028-$204F 129 #2ii5B-53S7F- $4000 17408 065 52450-52477 S2C78-.S2CTF $2400 9216 S4400 000 S242a-S244F 130 18432 001 $2400-52427 066 52850-52877 S307e-S307F $2800 10240 S4B00 S2300-S2827 S2828-S284F 131 S2C50-52C77 11264 003 067 $347e-S347F S2cae S4C00 19456 002 S2C00-$2C27 068 S2C28-S2C4F 133 132 53050-53077 $3000 12288 20480 53e73-S387F S5000 004 S3000-S3027 069 S3028-$304F 13312 21504 005 53450-53477 $3400 $5400 33400-53427 070 S3428-$344F 135 134 53C7e-S3C7F $3800 14336 55800 22528 S3828-S384F 53850-53877 $2aFfi-S20FF 23552 007 33800-53827 071 53C50-S3C77 53C00 15360 006 53C28-53C4F 524P8-524FF S5C00 16512 $3C00.S3C27 136 S20D0-520F7 $2080 8320 54080 32030-$2eA7 072 073 520A8-$20CF 137 524D0-S24F7 528Ffl-52SFF 52480 9344 17536 009 008 S24A8-$24CF 34480 $2480-$24A7 138 S28D0-S28F7 52Cty-S2CFF 10363 010 528fl8-$28CF 52380 S4B80 18560 S2880-$28A7 074 S2CD0-S2CF7 53aF8-538FF 11392 S4C80 075 076 $2CA8-S2CCF 139 534P8-$34ET 19584 $2Ce0-S2CA7 $2C80 12416 55080 20608 011 S30A8-$30CF 141 140 530D0-530F7 S3080 012 S3080-$30A7 53aF8-538FF 13440 S5480 21632 013 077 534D0-S34F7 S3480 53480-$34A7 $34A8-S34CF 53CFa-$3CPF 22656 014 078 142 538O0-S3ap7 S3880 14464 S5880 S38S0-S38A7 $38A8-S38CF 15488 23680 015 079 143 53CD0-53CF7 52178-S217F S3C80 S5C80 S3C80-53CA7 $3CA8-S3CCF 145 S2100 16640 016 080 144 52150-62177 5257B-52b7F 8448 $4100 S2190-$2127 081 $2128-S214F 146 S2500 9472 54500 17664 52500-52527 52550-S2S77 52978-S297F 10496 S4900 017 018 082 $2528-S254F S2900 18688 S2900-S2927 52950-52977 S2D78-S2D7F 083 $2928-S294F 147 52D50-S2D77 S2D00 11520 54D00 19712 019 $2D00-S2D27 $2D28-S2D4F S3178-S317F 12544 55100 20736 020 084 148 53150-53177 S3100 53100-53127 $3128-S314F S3578-S357F S3500 21760 021 085 149 53550-53577 13568 S5500 53500-53527 53528-S354F S3978-S397F 3 3900 14592 S5900 22784 022 086 150 53950-53977 S3078-S3D7F 023 53900-53927 $3928-S394F 151 S3D00 15616 SSD00 S3D00-S3D27 S3D50-S3D77 23808 0B7 53D28-S3D4F 152 S21F8-S21FF S2180 8576 S4180 16768 52180-S21A7 $21A8-521CF S21D0-$21F7 9600 54580 17792 025 088 089 153 S25F8-525FF S2580 024 S2580-S25A7 S25D0-S25F7 10624 18816 026 525A8-S25CF 154 S29F8-529FF S2980 $4980 52980-$29A7 S29A8-S29CF S29D0-$29F7 $2DF8-52DPF S2D80 11648 S4O80 19840 027 S2D80-S2DA7 S2DAe-S2DCF 155 S2DD0-S2DF7 12672 20864 028 090 092 531D0-531F7 531F8-$31FF S3180 $5180 S3180-S31A7 531A8-531CF 159 $35F8-535FF 13696 55590 2188S S3580-S35A7 091 157 S3580 $35A8-S35CF S35D0-S35F7 $3980 14720 $5980 22912 029 031 030 S39B0-S39A7 093 094 539Ae-539CF 158 S39D0-539F7 $39F8-S39FF 23936 156 161 095 $3D80 15744 55D80 S3D80-S3nfi7 S3DA8-S3DCF S3DD0-S3DF7 $3DFB-53DFF S2200 B704 S4200 16896 032 S2200-S2227 096 S2228-S224F 160 S2250-S2277 S2278-5227F $2600 9728 17920 033 S2600-S2627 097 S2628-$264F 52673 -5267F 52650-52677 S2A00 10752 54600 13944 034 098 163 162 52A78-52fi7F $4A00 19968 S2A00-S2A27 S2A28-S2A4F S2A50-S2A77 $2E00 U776 $4F.00 335 S2E00-S2E27 099 52E28-52E4F 20992 S2E50-52E77 52E78-52E7F S3200 12800 $5200 036 S3200-S3227 100 164 53250-53277 22016 53228-S324F 53 278-5 327F $3600 13824 S5600 037 S3600-S3627 101 103 S362B-5364F 165 53650-53677 53678-S367F $3A00 14848 S5A00 23040 038 S3A00-S3A27 102 S3A2B-53A4F 166 24064 S3A50-S3A77 53A7e-S3A7F S3E00 15872 S5E00 039 S3E00-S3F27 S3E2e-53E4F 168 167 3832 041 S3E50-53E77 $3E78-$3E7F S2280 $4280 17024 040 S2280-S22A7 104 $22A8-522CF 9856 522D0-522F7 522F8-S22EF S2680 18048 S2680-S26A7 105 S26A8-526CF 169 10880 54680 171 S26D0-526F7 S26FB-S26FF S2A80 $4A80 19072 042 S2AB0-S2AA7 106 S2AA8-$2ACF 170 S2E80 11904 $4E80 20096 043 107 52AD0-52AF7 S2E80-S2EA7 S2EA8-$2ECF 52AFe-S2WF 12928 21120 044 52ED0-52EF7 S3280 $5280 S3280-S32A7 108 109 S32A8-$32CF 172 S2EF8-S2HFF 13952 22144 045 S36A6-536CF 532D0-532F7 S3680 S3680-S36fi7 173 S32F8-S32FF $3A80 14975 55680 23168 046 S3A80-S3AA7 110 111 S3AAB-S3ACF L74 536D0-S36F7 S36F8-$36FF 55A80 24192 047 S3AD0-S3AF7 $3E80 16000 S3E80-S3EA7 113 S3EAB-S3ECF 175 S3AF8-53AFF 55E80 17152 049 $3EDO-S3EF7 S2300 B960 $4300 048 52300-52327 112 52328-S234F 176 9984 52350-52377 $2700 18176 52700-52727 115 S2728-S274F 177 S2378-$237r 54700 S2750-52777 $2B00 11008 S4B00 19200 050 $2B00-S2B27 114 178 S3EFB-$3EIT' 052 S2B28-S2B4F $2B50-S2B77 52778-$277F $2F00 12032 $4F00 20224 051 S2F00-S2F27 S2F28-52F4F 179 S3300 13056 21248 S2F50-S2F77 S2B78-$2B7F S5300 53300-53327 116 S332B-S334F 180 63700 14080 22272 053 S3728-5374F 53350-53377 52F78-52F7F S3700-S3727 117 118 181 53750-53777 S3B00 15104 $5700 S5B00 23296 054 S3B00-S3B27 S3B28-S3B4F 182 $3378-5337F 16128 S5F00 24320 055 53850-53877 5377a-5377F $3Fa0 17280 S3F00-S3F27 U9 S3F28-53F4P 183 $2380 9088 056 S23A8-523CF 186 $3F50-S3F77 S3B78-S3B7F S4380 $2380-S23A7 120 184 S23D0-S23F7 S2780 10112 18304 057 S2780-S27A7 S27A8-S27CF 53F78-53F7F 54780 121 123 185 S2B80 11136 19328 $27D0-$27F7 S23F8-523F^ 54880 058 059 52BB0-S2BA7 122 S2BA8-S2BCF 12160 20352 060 $2M)0-52BF7 $2F80 54F80 52Fe0-S2FA7 S2FA8-52FCF 187 527P8-527Fr S33S0 13184 21376 124 52FD0-S2FF7 52HP8-S2BPP 14208 $5380 22400 53380-$33A7 S33A8-533CF 188 $33D0-S33F7 53780 55780 061 S3780-S37A7 125 S37A8-537CF 189 52FF8-$2FFF 15232 S5B80 23424 063 062 53B80-S3BA7 $37D0-S37F7 $3880 126 S3BA8-S3BCF 190 S33Ffl-S33FF $3F80 16256 2444B 53F8B-53FA7 538D0-S3BF7 $5F8a 127 S3FA8-53PCF 191 $3ro0-S3FF7 53HF8-S3Bff $37E«-$37n' Figure 5& HIRES Displayed Memoiy Map. S3FF8-S3Fn' ,;;jiJ RAM and Memory Management 5-15 SCREEK TOP HSRIZCNTAL HLfiKKIHG (HBL) HDRIZCWTAL DISPLAY ENABLE 11111111 111111111111111122222222 UHE 00123456789ABC3JEFB1234567 PJCE 2 PflB: 1 PAGE 2 01234567a9ABCDEF0123456789ASCDEF01234567 KM 8296 9216 6192 $4000 16384 4 l-M I t I U I I I 16488 9320 $4068 17512 10240 $4400 17408 $24ea 10344 $4468 1B536 !■####++++++ S2000 $4800 18432 $2866 $2400 $4868 19560 11368 $4C68 l-####-H^-H-f 11264 $4C00 19456 $2C6e $2300 12392 20584 12288 $3000 20480 I 111 11111 111 1 $3068 S2C00 13416 $5068 21608 +*#«* $3468 $5468 $3000 13312 $5400 21504 1444£) 22632 14336 $5800 22528 I I 1 1 I I I I n I i-\- $3868 $5868 23656 53800 $3400 15360 $3068 15464 (-##()#++++++ 53C00 $5C00 23552 MI M I tM M M H M ^■t■H-^■ i+i' 6424 $5C68 16616 +#»*» B320 540B0 16512 M M M I In I II 9448 $40E8 17640 $2080 9344 $4480 17536 H In M I n In $24E8 $44E8 10368 $28EB 1B472 18664 $4880 18560 H-t-t f t M t >4 f-f 52480 11392 -4-h4 H M t I M t 11496 $4eEe 19688 S4C80 19584 $2CE8 $4CE8 $2880 12520 20712 $30Ge $2C80 12416 $5080 20608 I H M n M I M4 13544 $50E8 21736 $3480 13440 $5480 21632 IM I IIIM I I II S34E8 $54E8 22760 14568 $3880 14464 I I I I jl I J I I I ] I $3aE8 $58E8 $5880 22656 $3aiB 15592 J5CE8 23784 15488 $5ca0 23680 +4V-t t-« t-t \ H 14- 16744 8448 54100 16640 $2168 8552 $4168 17768 53CS0 9472 I M I M M Ml 14- $2568 9576 $4568 $2100 10496 54500 17664 I I I I I M I I M 4-> 10600 18792 $2963 $4968 $2500 12544 54900 1BGS8 11624 19816 11520 $2D68 $2900 54D00 19712 12648 $4D68 20840 13568 $3168 $2000 14592 S5100 20736 $3563 13672 $5168 21864 $3100 $5500 21760 14696 SS568 22868 $3500 55900 22784 $3963 15616 15720 $5968 23912 $3D63 $3900 $5000 23806 8680 $5D6S 16872 $3D0e 8576 I III II IM IIH I $21E8 $4180 1676B 9704 541E8 17B96 9000 10624 $25E8 $21BB $4580 17792 1072B 545E8 18920 i I I I-+44-H- MM $29E8 5258C 11648 n M M I I IM I I 11752 S49E8 19944 $2960 54980 18816 1 M I M M I IM I $2DE8 +**##-l-H +#((##++4 $4080 19840 $31E8 12776 S4DE8 20968 12672 M M IM II M I I $2080 $5180 20864 13800 $51E8 21992 13696 55580 21688 $35e8 +#J##-H-t $3180 14824 $55EB 23016 +#*##+-H +####++4 14720 55980 22912 M M M I » t4 i M $39E8 $3580 15848 $59Ee 24040 15744 IM M I M n n $313E8 SSDES 17000 +####++4 $3980 $5D60 23936 $2263 ■+####■(-+4 16896 M II M M I IM j $2663 9832 $4268 18024 ■+»###+++ ■+*###+ $3D80 9728 8704 17920 $2A68 10856 S466B 19048 $2200 10752 $4200 M M III LM M t $2600 $2A00 11880 $4A68 $4600 S4A00 $2E6a 20072 11776 12800 19968 $3268 12904 S4E&8 21096 S4EO0 18944 13928 $5268 22120 $2E00 22016 $3668 13824 20992 14952 S566S 23144 53200 55200 MM t + t4-4-+4 $3R68 24168 ■+UU-H-* $3600 14848 55600 55A00 15976 S5A6e 23040 24064 M M M t 4M t-t-M 1-4-M t-t-+ I I $22E8 8936 $SE6B 17128 +##*#4 S3A00 10£ 15872 17024 M IM M M M M $5E00 $26ES 9960 S42E8 18152 $3EO0 8832 542S0 18048 M M M IM M H S46E8 S22Q0 109B4 19176 9B56 19072 M I M M4 M M t $2AEB 54680 S4AS0 12008 $4AE8 20200 +####4-H 4-*###4-H S26S0 $2£E8 $32Ee 13032 $4EE8 21224 $2A80 11904 12928 21120 SS2E8 +«###4-H 4-####4-H S2Ee0 $3eES 14056 S56E8 22248 13952 $4E80 22144 M IIF >I IM M 1S0B0 ■?4 4-####4-H $3280 $3AEe 36S 23272 S5AE8 $5280 23168 16104 24296 4-####4-H $3680 14976 55660 ^■####+4^ 1600S 24192 9064 S5EEB $3A80 ?536r 17256 4-####4-M 53Ee0 8960 $5Aa0 17152 H n u n ^ + ^-++ 10088 $ 18280 $5E80 18176 *■ M I M M I 4- 4 4 52768 47 4-####+44 $4300 11112 5 68 19304 $2300 9984 11008 19200 f If H M M M I $2B6a 4S68 12136 $ $4700 4F68 20328 ?2P68 4-####-t-H $2700 20224 H M IM M M I I 13160 4-####4-H S2EO0 12032 $3368 55368 21352 $4B00 21248 I I I M I I II I M I 14184 22376 4-### II I II 64 52010 52028 8232 65 9232 54010 16400 17448 54410 17424 52428 9256 54028 18472 I I I n I I I H I IM M HIH. 66 S2410 10256 +♦###++++■ IIIIIH III Mil Mil S2ai0 67 S2C10 112M 54310 18448 54C10 19472 ■+####++++ +M##'H-+-t- 52828 10280 19496 5442S 20S20 >I M >-H- 68 52C28 11304 54828 S3010 12304 56010 20496 53028 12328 I III IIII H M Im I IM I II 69 13328 55410 21520 53428 13352 S4C28 21544 70 S3410 M I I I M > I I 1 I M n I IIM MM <-t-H M M I I II IIH IM M I II I 53810 14352 55810 22544 -f#tt#++-H- $3828 14376 55028 22568 II 1 1 1 n I H riTTTH 71 15376 <-»##«+-H-t- 53C10 JSCIB 23S6B 53C2B 15400 55428 55828 520961 8336 16528 54090 17552 9384 8360 55C2B 16552 23592 17576 I HH I I I I Mil M I I lintt 520A8 540A8 18600 I I M I M I M I I I I I M ^^ II 52490 9360 54490 10408 ++++ I lin M M I ...+H-H 1 1 1 1 1 I1 52890 10384 54890 18576 524A8 544A8 19624 19600 11432 ++++ S2C90 11408 S4C90 52SA8 $48^8 20646 12432 12456 53090 55090 20624 52Cfte 13480 54CA8 21672 I I I I I t H 1 II I H HI I I I11I MilM I 13456 21648 53490 55490 530Aa 14504 550A8 22696 14480 22672 53890 Ml t I n I I I I II I IMI I MM III llt> IH 80 S3C90 15504 55390 23696 534AS 15526 53aAB 554AB 23720 55C90 ?5aAB 16680 H M M M IH IH 52110 15656 53CA8 81 S2510 8464 9488 54110 17680 S4S10 ■+»###+++++ -+####++-H- 52128 9512 8468 55Gfte 17704 54128 18728 II III IIU IM M IIM IIIH I> m M.HIIH III MM B2 10512 18704 10536 ++++ 52910 52528 M H M I I ) UtI M I I I I I I 111 I 83 11536 54910 19728 -4-####-H-H- 11560 19752 52D10 S4D10 20752 52928 12584 54928 20776 54528 H-tlt-ft-f I M M t I I M I I I I I I I M II I 84 12560 S2D28 53110 M I M I Ml mil II I I tlllMI MM MlII 85 13584 55110 -+####-M-H- 53128 13608 54D28 21800 86 53510 14608 55510 21776 22800 14632 55128 22824 I H M I > I I I > I M I II 53910 55910 +###«-H-H- S3528 15656 55528 23848 I I III I IH IM IIIM I 15632 23824 53Dia 8592 55D10 16784 53928 55928 16808 I II II 87 53028 89 52190 9616 $4190 17808 9640 8616 S5D28 17832 M M I M I I I M I I M M I M Ml> 90 52590 54590 1B832 54IflS 18856 I I I I I M I I I M I I I I I II n I I It 10640 52iAe $25AB 10664 11688 52990 11664 91 54990 19856 54D90 20880 +####++++ S29A8 545Aa 19880 I I I I I I H I II M M II I I II I IM I I I III lllll 92 521)90 12688 52DA8 20904 I M II I M I MIM S319B 13712 55190 21904 +#### +####++++ 12712 13736 S4DAB 21928 M M I I I I M I I I M I I I IIM M I 93 53LSfl 549AS 94 53590 14736 55590 22928 ++#### 14760 S5UB 22952 M I I I I I I I I I I M M I Ml M H I 53990 55990 23952 S35AB 555A8 ++-HI I I II I I I I I I I I I I II II MM 95 15760 +###»++++ 15784 M $3D9C 5J9A8 8744 5S9AB 23976 96 8720 5SD90 16912 16936 I IIMil 52210 53DAB 9768 S5Dft8 17968 54210 17936 ■ t I nni.tnnn-»ni I mill S2610 9744 54610 18960 5222B 54228 97 98 10768 S4A10 10792 54626 18984 I m I M I I M I II I IM I II I III 99 S2A10 52628 11792 19984 11816 20008 nil I I III I I I I III III 52E10 S2A28 54A28 54E10 21008 12840 21032 100 53210 12816 +####-H-l-+ 52E28 54E2e I M I I I I I I I 1 1 f mt+t ♦■>■» H4 lei 53610 13840 55210 22032 53228 13864 22056 ■^-n+H■^-^t■^■H^*^l mimimi 102 14864 55610 23056 14888 55228 23080 S3A10 5SA10 24080 5362S 55628 I I I I I I It H-t-H H H M M n H' 103 53E10 15688 S3A2B 15912 24104 I II I II I Ml nil II I iiiiiitt 104 8848 55E10 17048 8872 S5A28 17064 +#»#t-H-K I M I M I II HUM Min $2290 54290 18064 4-t-++ 52690 9872 53E28 9896 10920 18088 10S 54690 19088 522AS 542A8 I M I M I I I I M M' It' I I I I I I I M 106 10896 526AB 20136 19112 I II I I I I I 1 I II I I I M I I I I I III 107 52A90 11920 54A90 20112 11944 S2E90 54E9e 21136 546A8 f5E28 I M I M II I I II I I I I I t M I 1144 10S 53290 12944 52AAB S2EAS 12968 $4Afi8 21160 109 13968 55290 53690 22160 13992 552fla 22184 ++++<■! H I I M 1 I I > I I Mll-H-*- $32A8 54BftS I 1 1 I I I II H I I I I HI I I I I M I I 110 $3A90 14992 55690 23184 536AB 15016 23208 55A90 556A8 111 16016 16040 24232 $3E90 S5E90 24208 17168 53flAB 55Afte 11I Illlllll I m' I I I I I I I I I I I I I 11 M I I I I 112 52310 8976 17192 54310 18192 55EAe 113 10000 53Efta 52328 18216 I H II I I I M I I I I I II II lllt»t 114 52710 11024 $4710 19216 +####+++4 11048 54328 19240 II M I I M Illlllll 52B10 52728 10024 115 12048 54B10 20240 54728 54828 ++++ I I II I II I II I I II Ml I I III III 52F10 S4F10 21264 52B28 12072 +-t-H-*-l-H II I Ml II I I I MINI 116 S2F28 13096 54F28 21283 53310 13072 $3328 117 55310 22288 9000' 20264 $3710 14096 55710 23312 53728 14122 55328 22312 II II I I I I I M II I I 1 1 I I I I Hi 1 1 118 53B10 15120 15144 55728 23336 II M I H' Ml 4 M I I I I I I 1 1 H I ' 119 16144 S5B10 24336 55F10 1616S 55828 24360 I H I IM M I IM III I M IIIiiinii 120 53Fie 9104 17296 53B28 5SF2B H I H I I I M I I I I I I « 55BAa 55FA8 53f1^ I< I IM M t II I I I I I I »■»<■ Figure 5.9 HIRES Scanning Map including Undispiayed Areas (2 of 4). RAM and Memory Management 5-1 7 SCREEN BCTICM HORIZONTAL BLANKING (HBL) HOtUZOWTAL DISPLAY ENABLE -l-l-HH LINE limill 111111111111111122222222 PAGE 1 PAGE 2 001234567S9ABCOEF01234567 P*GE 2 NUM 52038 8248 54D38 16440 ■!■*■■ «#»»H 1 1 H PAGE 1 0123456739ABCDEF01234567a9ABCDEF01234567 52050 8272 54050 16464 I I I I ' H I I M I I I I I n M I I I I I I I I I I I 128 I I I .t. 129 52438 9272 54438 17464 ■n I H 1 1 I i«##ti M n->- 52450 9296 54450 17488 1 I1 'H 1 1I 'I 1 1 1 II t- I 111111111111111 IIII 130 52838 10296 54838 18488 I I#*««MI 11+ 52850 10320 54850 18512 tM M IIItIII 131 S2C38 11320 54C38 19512 +++++++++####+++++++++++■ 52C50 11344 S4C50 19536 I I tl I I 1 1 I I 1 I IIm 132 S3038 12344 55038 20536 <-#t*t++i I I n u I I I 55050 20560 53050 12368 ' I 1 1 I I M 1 1 1 1 1 n M 1 1 1 1 1 1 1 1 1 I i I 1 1 1 1 1 I i-f 133 S3438 13368 55438 21560 I I I iJ I I I i|t#m-n I 53450 13392 55450 21584 134 53838 14392 55838 22584 tttt * IIIII 53350 14416 55850 22608 M' I II 'I II M I I II II II I11I II 1I II II I I I 'I II MI I II [I MI I II II II II II tI II It IiII IIIIII 135 3C3S 15416 55C3a 23608 <+H-HMH.t««#l 111 S3C5e 1544e 55C50 23632 1 1 1 1 1 1 I 1 1 I I I II I I n n I 13C 8376 54088 1656B ti »tt t«i I n 1 1 1 1 1 1 1 1 1 1 1 1 1 H I i I I I I I I I I I I i I I I I I I I I I I- 137 52488 9400 54488 17592 520D0 8400 540D0' 16592 *»U i-t- 524D0 9424 544D0 17616 111I ' In 111 1111n 111 130 548B8 18616 l-l-l I I I I I I I I I I I M ft. 52868 10424 44-1- 528D0 10448 S48D0 18640 4-#t«#++l I i M I n 1 1 1 1 1 1 1 1 1 1 4. 139 52CBe 11448 54CS8 19640 -H-t|.| I I I I jfjtjt#i-4- I I I I 52CDe 11472 S4CD0 19664 IIIIIIIIIII I111 I11111I 11111 140 53flBe 12472 55088 20664 -HI tm-H-l II H 530D0 12496 550De 20688 I I I I I I I I I I I I I I I I I I I I I I I 11 I I ! I I I I I I 141 $34BS 13496 554B8 21688 II II II H+#«#»ll I III II Mil S34D0 13520 554D0 21712 1 1 1 1 1 n 1 1 1 1 1 1 1 1 1 1 1 1 ^-+^| ' I 1 1 I 1 1 1 1 M I i 1 1 142 S38S8 14520 558B8 22712 ■«-##»* Ill 53300 14544 55BD0 22736 ' n I 1 1 1 1 1 1 1 1 1 1 1 1 I I I t t-i 1 1 I 1 1 I I I M I I I I I t 143 53CB8 15544 55(38 23736 »♦#♦! MM 53CD0 1556S 55CD0 23760 144 l-H I I I I I I I I I n I M I I I I I I I I I I I H H I I I I H. 521 38 8504 54138 16696 II I i I I tl li^##*ll I 52150 8528 54150 16720 M 11 I I I II Mill II t I II II II IIII I I l-l iILI 145 52538 9S2B 54538 17720 H M I I I l + «j|»# I I I IH- 52550 9552 54550 17744 11 111 111 11i 11 111 11 111 146 52938 X0552 54938 13744 K+-H-«»#;H I II it-I- 52950 10576 54950 18768 I I M II I I I It 1111111+ S2D38 11576 54D38 19763 ll I I I M I ltt##l I M I t $2D50 11600 $4D50 19792 I I I I I I ■-l-l t I I I I I I I M I I I I I I t t t- 147 143 53138 12600 SS138 20792 -til I I I I M###tM I I 53150 12624 551 50 20816 149 IIIIIIIII II Ht-I I 1 I4-4-t IIIM IM 53538 13624 55538 21816 tn I I I I ll#t**l III 53550 13648 55550 21840 tl-t I I M 1 I I I I 11 I I I I I I I I I I 150 53938 14648 55938 22840 Mil 55950 22864 t«##.H..HI I 53950 14672 Ijl I I I I M I I I I t I t-l I II I I lt-1 151 53D38 15672 55D3e 23864 until !+«###+ T?r 8632 541BS 16824 +++++++++*###+ S3D50 15696 S5D50 23888 III I I I I It I t It-I I teiee 521D0 8656 541 D0 16S4B I I I I i Itf I I I I I I I I I I I 11 I It-t"H I I I tI tI tI H- I I ++-t t-l t 153 525Be 9656 545B8 17846 III I I I I I I 11 I I I I Ill mtt'l I M M I I M I S25D0 9680 545D0 17672 IIII II 154 529Ee 106SB $49B8 18S72 'II ItttI II I 11 > 529D0 10704 549D0 18896 155 I I I I I I I I I I I I I tl I I I I I 52088 11704 $4DB8 19896 ' I Ml H H#« t tl I I I I I III I I I I t I- l-f t- 156 52DD0 11728 54DD0 19920 I I I I I I I I I I I I I I > I H I I I I I I I I I I IIIII 531B8 12728 551B8 20920 tllltff#«+ 531W) 12752 551D0 2a944 N 1 I I I I M I I I I I I I I I I I I I II n 157 53588 "13752 §760 555B8 21944 I Ijttt* 555D0 21968 I I I I I I > I I I I I I I I I I I I I I I I I I I I I I 158 53988 14776 53SD0 13776 159 53DBB 15800 55988 22968 +i ttUK in 539D0 14800 559D0 22992 I I I I I I n I I t I I I I I I I I I I I I I 1 1 I I I I I1 I1 It Il-tt-+ III lee 55DBe 23992 I tttn-t 531100 15924 55DD0 24016 ' M I I I I I I I I I I I I I I I 1 I I I I I I I I I I I I I I I I I I I I I 161 5223a 54238 16952 M ««##H III 52250 8734 54250 16976 I 1 1 1 1 1 1 1 1 1 1 I n li t-l 1 1 1 1 1 1 1 1 1 1 52638 9784 $4638 17976 1 1 m i + H-|t*##i I 1 1 1 I Mti+f I 1 1 1 1 1 1 I 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 I I 1 1 1 1 1 I t-t 162 52650 9S0B 54650 18000 52A38 10808 54A3S 19000 163 52E38 11832 H-#*##+ 52A50 10832 54A50 19024 ' I I I I t M- 1 t I I I I I I t I I I I I I I I I l-t-i-f I I I I t I !■ t -t 54E3a 20024 11 I II n I I M I M M I I I I I I t-l H-l-l I I I I I I I I 164 53238 12856 52E50 11S56 54E50 2004S 165 55238 21048 11 I»t##l I Ill 53638 13880 55638 22072 53250 12880 55250 21072 III I I I I M 1 l-tt Mi I1 II1I 166 53A3e 14904 55A38 23096 ■H l-l I 1 I IHt»#t l-i 53650 13904 55650 22096 I I I I I I I I I I I I I I I l-t H I I I I I I I I I I I I I I t I I H -l-l- 167 $3A50 14928 S5fl30 23120 I I I I I I I I I I I I I I I IIII 1 53E38 15928 55E3a 24120 ■*-» I I ilt»*-l-t-H-l-l 53E50 15952 55E50 24144 -t-f-H't-l t-H I I I I I I M I [ I I I I I I M I I t-t.t+ 169 nil in+n t# » Mil 522D0 8912 S42D0 17104 I I I I I I I I I I t I I I I I I I I I I I I I I I I I I I I I I It-l-t II I I tiltI I S46B8 17080' 526B8 9912 "i42B8 18104 nil iin-H*** nil 526D0 9936 S46D0 18128 l-H-l I'l I I I I I t t I I I i I IIIIIIIII 170 52ABe 10936 S4ABe 19128 +++++++++####+ I I I I I t I tM t-l-t I I I I I I I I I I I I I 1 I I I I I I I I I I 171 52EBe 11960 52AD0 10960 S4AD0 19152 172 54EB8 20152 -n I #t## 52ED0 11984 54ED0 20176 I I I I I I I I I I I I I I I IH IIIIIIIIIIIIItI 532B8 12984 55288 21176 II' «t«ti II It 532D0 13008 173 536B8 14008 556B8 22200 ++++++*++####++++++++++++ 552D0 21200 l-Ht-l I t-f-l I I I I I I I I I I I I I I I tl-t-l-t-l ft I I tt-t-lI I I I II II It II It II- 174 536D0 14032 556D0 22224 I I I I I I I I t t t-t t-f-H 175 53AB8 15032 5SAB8 23224 I M I I I l-H-#### g3EBa 16056 55EB8 24248 <-> n I I i+i-»t#t+ 53AE30 15056 55AD0 23246 I I li I I t I I I I I I I I HI I I I I I I I I I I t U I I I I I I I I I 53ED0 16080 55ED0 24272 I I I I I I M I I I I I I I I I n I I I I I I I I I I I I I I I I I I t I t rre W338 9016' 54338 17208 +++++++++## # ft I H M I I I I I I $2350 9040 IT' S273S 10040, 54738 18232 < 54350 17232 I M 1 1 I I HH I I I 1 1 1 I 1 1 I III I I I I I I I I I I I n I 1 + «t*«M III ITO 52336 11064 54B38 19256 52750 10064 54750 18256 I I 1 1 I I I i-i It 1 1 1 1 1 1 I I I I I I I I I I 1 1 1 I 179 I n-f####i 1 1 1 1 1 I >i I M 52850 11088 S4B50 19280 I I I I I I 1 1 1 n I I 1 1 I I I I 1 1 1 t nt M I I I I 180 52F3e 12088 54F3a 20280 I I I I I I H-t###t I i I I I M )>!■++ 54F30 20304, I I I 1 1 I I I I I I I I 1 1 1 1 1 1 1 I I I I I It I 5333 8 1311 2, 55338 21304 -l-tl 1 1 1 l-t-t-t#lt 52F50 12112 181 I 53350 13136 1 1 1 1 I I 1 1 I I I I I I I I II I I 1 1 I tl 1 1 I I I I I I I 1 1 I 1 1 Lffl 53738 14136! 55738 22328 +«-H-H-H-# # (t # ++++++++++++ 55350 21328 53750 14160 55750 22352 1 1 t-l mn 1 1 1 1 1 1 M 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > I M 1 1 1 1 L83 53B38 151601 55B38 23352 'II «#lf# <■####++++++++++++ 53E50 15184 55B50 23376 t It I I I I I I I I I I I I I I I I I It I I I I I M I M M III 9144 55F38 24376 t I I tt I t-t t-l I I I I |t-H-|-f++ I I I I It 185 l?43Be 17336 n **»*tH 53F50 1620B $5F50 24400 I I I I I I I I I I I I M I It- 1 I I I t I I I I I I I I I I I I I I I t I t- lae 52768 leies 547BS 18360 tHH-H-H-H-##ttll I 523D0 9168 54300 17360 527D0 10192 Ssaee 11192 54BBe 19384 II I I I I I I lt###l t I 547D0 18384 H I It I i-H 1 I I I I I I I I I I I t I t-l I I I I I I I I I I t I I I t 187 52iB8 12216 I I I I I I I I I I I I I I I I I I t^ t I t I I I I t IH It If 54FBe 20406 >>+###» 52BD0 11216 54BM 19408 L88 S33B8 13240 52FD0 12240 t-ttH t I H I I I I I I I t M I I H I t-l I I I I I I I I I M I I I I 1B9 53788 553B8 21432 >ntt#t I 533D0 13264 54n» 20432 I I I I I I I I I I I I t I I t M -I I I I I I I I 1 I I I I I I I I I I n 190 14264 55786 22456 H lt»#t-HI-H 537D0 14288 553D0 21456 H -t-l tt It t It I t I I I I I I I I I I |.»t t I t t I I I I I I I t I 191 ?3aB8 15288 55BB8 23480 n *«»» u 557D0 22480 m I 1 1 I I I I 1 1 1 I 1111I t I>III 53EB8 16312 S5FB8 24504 inni i>i#t»# 53BD0 15312 55BD0 23504 53FD0 16336 ' 111111 II 55FDe 24528 Figure 5.9 HIRES Scanning Map Including Undlsplayed Areas (3 of 4). «?- 5-1 8 Understanding the Apple lie VEHTICftL BIAHKING PERIOD (VBL) HDRIZCHTAL DISPLWf ENABLE 1I11U1111111H122222222 HDRIZCHTAL BUMKING (HBL) LINE nilllll 0123456769flBCraP0123456 PAGE 1 7B9ABCDerai234'i<;T NUM PAGE 2 00123456789AECDEFei234567 PAGE 1 TS504 PSCE 2 I 1 1 1 1 1 I H 1 1 iMi nn > I M I m+4+t $2060 16480 1 1 1 1 1 1 1 n 1 1 14 1 1 1 1 1 n 1 1 1 1 n 17504 tHHItHMii? 17528 $4060 193 9312 +#>##< 18552 I l■^^^t■^»^^^>^>^^ 1 1 1 11 n n 1 11 1 1 194 5"$2460 10336 54460 1B52S 9336 S4078 19515 ?2860 113604 54860 19552 ?2478 54478 19576 > m I'M <>-M I H M I M I I II I II IllK 11334 10360 196 52C60 ^ 1238 8535S4C60 $2878 12408 54878 20600 M n I n 1 1 1 1 1 1 1 1 M 1 1 M II 1 1 1 Kt ?3060 408 20576 H M U M I M III M I H n M I I (. S4C78 197 ?3460 13 32 $5060 $5460 22624 21600 <■####++++++++ S3078 $2C7B 13432 21624 HI I I I I I I I M I I I I I I I I I- I imiii. 4 1989 ?3860 14 ■H* *++++++++ 154S0 14456 55076 22648 23672 1 I I I t-> H-M I I I M M I I I I I I I I I I I I I I I I I H4^ 19 ?3C60 1 5 456 55860 23648 ■t*«*4t'it II n 53478 55878 16632 200 ?20Ea 8416 16608 $3878 "BSS55478 M H II I n^- 9464 ff +##it#M I M+++ ?3C7e 8440 17656 201 524E0 9440 540B0 15C60 17632 S20Fe !■ I M H > n H I H I I I I I n I I I 1 1 M I u I M I I.H 202 $2BE0 10464 544 E0 18656 10488 54eF8 55c7a I I I H I I in ■ 'I 1' I■ Hr I' I1 I1 I1 HI I I I IMIIH 1 1 1 1 1 11 1 1 1 1 1 1 1 1 n 1 1 548 E0 1-tftft I 18680 MM n 1 1 1 1 1 1 1 1 11 1 111 203 S24F8 $44F8 11483 19680 <-##«* I 528ra S48Fa 19704 I( II III I IM II 204 $2CE0 12512 54CE0 20704 52CF8 11512 12536 S4CF8 20728 I 1 1 1 1 It t ' 1 1 1 1 n M 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 III 205 53ME0 13536 550E0 21728 +#tt«4-4-l ht-l++ 13560 21752 ^-t-t-t-tH-ni HI HI II M I m 1 1 1 1 mini III 206 $34E0 ?3BE0 14560 554B0 22752 t*tt» 'I- 530FS 14584 $54F8 550FS 22776 207 15584 55eE0 23776 ■+»#»«l I I II I I I 534FS 15608 23800 I I I Mil Itl I I I I I I I I I H I II I I I I I I I nil IH 208 53CE0 8544 55cm 16736 $5eF8 T57ES I II 1 1 1 1 1 1 1 1 I H 1 1 1 II II I III I nun III iiT ?2160 538F8 HI 1 1 1 1 1 1 I n 1 1 >i I HI 1 1 nil 209 9568 54160 17760 9592 55CF9 17734 54560 53CF8 1 1 HI I H II I III 1 1 1 III II iiinu 210 $2560 113592 18764 52178 10616 18808 $2960 211 ?2D60 11616 54960 19S0S +####++++++++ S2578 11640 54178 54578 19832 M I I I H II I I I I I Mil IIIMI lit 212 53160 12640 54D60 20832 f#tj#-l-H-+++++ <-*H«ll I HIM t-H- 12664 54978 I 1 1 n I I )i I 1 1 II 1 1 1 H 1 1 III HtH II I II 1 in. 213 13664 55160 21856 52978 13688 54D78 20856 21880 HH H I fi I II 1 1 t-H H 1 1 n 1 1 1 11 1 1 mil 114 214 53560 55560 <-♦♦♦* -tn-tl-H- S3178 52D78 55178 I I I I H HI I I I I I I I I I H H I HI I I II I nil 1 II 14688 215 $3960 15712 55960 23904 22880 <■##!»++++++++ $3578 14712 55578 15736 I I H H I H I I I I I I I I I H H I I I I I n III I II I II $31360 S5D60 +#tt*n 53978 16888 2392S 216 8672 8696 55978 H I I M I I I I I I I I I I H I M II I H I I I II I I I I I II $21E0 S41E0 16864 53D78 217 9696 17388 TiJtfi-i-t-i-H-i-t 22904! 17912 M M H I 1 1 1 I H I H I 1 1 M I n I n n II I II 1 1 II 525E0 $21F8 55078 218 545E0 18912 I I M H I I I H I I M I I I I I H I H I I II I I I I inn 529EB 10720 $49E0 525Fe 10744 545F8 18936 19960 219 19936 11768 541FS I I I I I I HI I I I H I H I I I I U I II I II lllllll* 52DE0 11744 $4DE0 *nn 531F8 13816 intH i-t+) M H4'4 H M 1 1 H 1 1 1 1 II II nun 551F8 23032 222 535Ea 14816 S55Ea 23008 539E0 15840 $59E0 24032 ■tt*# I 535Fe 539F8 9720' i II I H I Ml HI M-HH II I I II I HI Hill inn 223 4-tm I I I I I H I I H+ 14840 24056 I I I II I I I M n M I M I I I I I I H I I I II I II I 1114 53DEe 224 8800 $5DE0 16992 3824 $59re 17016 #*H****#«**#t#t*#*#**###t«*«f*t««tttHt 15864 52260 53DF8 9648 55DF8 225 9824 54260 18016 5227B 18040 4*#*t###t****##*ll»*#*t«t**»t«*#*tlttt»tl 52660 226 10848 54660 19040 +++■ 52678 54278 19064 52A60 54A60 20064 10872 5551-8 -+++ 11896 20088 tt#t#»##*t**t**#**f****tt*«t*«#llt*ttitt 227 S2E60 11872 54E60 52A78 54678 228 53260 128% 21088 4-#«tt 12920 54A78 21112 H H M I I I H I I I H' H H II H H 4 H H I I n I I I I I 13920 55260 54E78 55660 22112 229 52E7S 13944 22136 III H II I I H H I H-IH H I H n H II iitniiill S3660 53278 230 14944 23136 14968 55278 23160 53A60 15968 55A6e I I I M I I I I I I H H I H H I H I H 4' 4 I 4 I H 4 I 4-t-4-H 55E60 24160 231 5367S 15992 55678 24184 M H I t-4-l' It M > H H I H I I I I n I I I I I II I I I I n I j3E6e S3A7a 232 8928 542E0 17120 8952 55A78 17144 H i-t It 4-4 4 1 t-t 1 1 1 1 1 1 H 1 1 >■ 1 1 1 1 II 1 1 II I II 1 1 n S22E0 233 526E0 9952 546 E0 1B144 53E78 9976 55E78 18168 1 1 M 1 1 1 1 H I H H 1 1 1 M 1 1 M H 1 1 1 1 1 H II inn S22F8 19192 234 10976 19168 11000 542Fa 546 FS 20216 1 1 1 1 1 1 H 1 1 1 1 1 H 1 1 1 H 1 1 n 1 1 H 1 1 II 1 1 II I ni S2AE0 526 F8 235 12000 54AE0 20192 12024 I I H I I HI 1 I H t-H-t-t-l II M HI n III Hill mil S2EB0 52AF8 236 13024 S4EB0 21216 13048 54AFa 21240 532E0 S2EF8 M M I H I I I I l-f H 4 I M I I I H I I III M I I I 237 14048 552E0 22240 14072 54EFa 22264 536E0 532F8 I H H Ml I I I I I I I I I I HI I I HI I till IIIMH 238 15072 556B0 55AE0 23264 15096 552F8 23288 I I I I M III I I H tl I I I I HI I I 53fiE0 536F8 S56F8 Mil 239 16096 24288 16120 24312 53EE0 ?3flFB S5flF8 240 9056 55EE0 54360 17248 9080 17272 I H 44 I I4-I 4 1-14 I HI I II H I I n I I H nil I I-H+ 52360 53EFe 241 52760 10080 18272 5237B 10104 55EFe 20344 19320 182 96 H I M I I I I I I HI HII III III nil till 242 11104 S4760 19296 11128 54378 H I I I I I I I I Ht-t-i III! 243 52B60 1212s S4fl60 20320 52778 ?2F60 52B78 12152 $4778 21368 I M It H t I I H H HI I I I I I H H H I it I n I I I t-H 244 13152 $4F60 21344 52F7S 13176 S4E78 II H HI Htt-H I I H I I I H I II I m lltH- 53360 55360 2236S 245 $3760 14176 $5760 23392 53378 14200 $4F78 55378 22392 4 4 4 ^■^-^ H+t 246 53860 15200 15224 55778 23416 I H I I I I I I HI++ I I I I I I I I III I I I H I I I I HI I ml 1 14'4 4 !■ 4 1 1 4 1 I 247 16224 55B60 24416 53778 53B78 16248 24440 I I 1 1 1 1 I H I 1 1 1 53F60 248 S23B0 9134 55F60 17376 53F78 9208 S5B7e 17400 10232 S43F8 18424 I I I I I I I IM I I I I I I I n 249 10208 ?43E0 18400 H IIH III II IttIII H. it** 527E0 547E0 S23F8 12280 ?5F7e t-t t H I I I H I H HH II IH-W 250 S2BB0 11232 54BE0 19424 52BF8 527F8 11256 19448 IIH H 251 S2EE0 12256 54FE0 20448 547F8 20472 I I H M I I I I I I t I t I I II II ml imiii I t IH-I' 14328 54EF8 252 533 E0 13280 21472 13304 $4BF8 21496 1 1 1 III I H-H-4 ' 14304 553B0 S37E0 15326 557E0 22496 253 S2EFe 22520 ++++++++4+ -H^^ II I I III H H I I I il iimt^- HH IIIIH I1 H1 1 InH I nII IIIiimiH- S33F8 15352 S53r8 t 254 53BE0 23520 24544 +++++ ?57iB 23544 H IIHt-H I HI H I I I H I H It I I I I II HHtn . 255 16352 5SBE0 537F8 16376 11256 S5BF8 53FE0 2456S 44 II H H M H I I I I I H 1 1 1 f ; 256 52aE0 11232 5Sm0 54BE0 19424 S3BF8 $3FFB 12280 SSFFB 19448 12256 +#t*t-H- 257 258 S2FE0 132B0 S4re0 20448 $2BF8 20472 H I I I I I I H H 1 I I I M II I It I I I I I I I H I I "*• 21472 13304 $4BF8 21496 ■H'»HI I t I tlI ItI IHH 144-11 I I I I n I.HI HI I I MUM' 259 533E0 $37Ea 14304 553E0 22496 +####++■ +####++■ S2FF8 14328 ?4Fr8 5S3F8 22520 Ml t I 557E0 $33F8 23544 I I I I I I I I I H II I 1 1I 1I 1I II 260 53BE0 15328 S5BEB 23520 +##»#++■ 15352 5S7IB S5BF8 24568 H IH III II II I I iHHiiim' II II I HMHIII 261 53re0 16352 24544 +*###++■ 537F8 16376 I lit1-4HH4-l-fI I ■M- 41114 I II II II II IHIH IH I H H-H H- ' $5Fi:0 +####++■ 53BFB S3EPa SSFTa +++H 4-HH IMIII* Figure 5.9 HIRES Scanning Map Including Undlsplay^ Areas (4 of 4). miW'^" RAM and Memory Management 5-19 Table 53 Screen Memory Scannlr>g Summary. LOCATION HBL SCREEN TOP Last 16 of THIRD 40 FIRST 40 arid UNUSED 8 SCREEN MIDDLE Last 24 of FIRST 40 SECOND 40 SCREEN BOTTOM Last 24 of SECOND 40 THIRD 40 VBL HBL' Last 24 of THIRD 40 UNUSED 8 and first 32 of FIRST 40 TIME term switches low one video scanner cloclc process of scanning RAM for video output, the (HAS' rising during PHASE 1) after V4 • V2 address inputs to RAM had to be assigned very care- becomes true (see Figures 8.5 and 8.17). HIRES fully. Only the ROW address assignments are per- TIME switches high one video scanner clock after tinent to this discussion, and these are shown in V4 • V2 becomes false. V4 • V2 identifies the last Table 5.3. four lines of the TEXT display, and the one scanner Generally, the low order outputs of the video clock delay makes the video data from RAM switch scanner are assigned to the RAM ROW address between HIRES and TEXT at the same time as inputs. This is natural since the low order bits other addressing inputs to the video ROM (see change at a high frequency. HO, HI, H2, SUM-A3, MIXED MODE SWITCHING in Chapter 8). SUM-A4, and SUM-A5 are the six scanning address V4 • V2 actually identifies scan lines 160 through inputs which change at the highest frequency, and 191 and 224 through 261. The scanned memory these are all RAM ROW address inputs. Every switches to HIRES during the first part of VBL, horizontal scan, these six terms will go through all back to TEXT for the second part of VBL, then back of their possible states. to HIRES for the top of the screen. The switching SUM-A6 is the next highest frequency RAM during VBL is, of course, not visible on the screen, addressing input, but it is inappropriate as a ROW This information is only important to those special address input. This is because SUM-A6 and the applications where it is important to know what is lower order addressing terms form a 128-state word scanned during the blanking periods. of which only 64 states are scanned during a hori- The following is a reference list for scanned zontal period. The 64 scanned states remain constant memory in the HIRES MIXED mode: during each of the four quarters of the complete vertical scan, so in each quarter, there are 64 Line 0, HPE' + 1 thru unscanned states. For example, in the top third of Line 160, HPE' — HIRES, Figure 5.9 Line 160, HPE' + 1 thru the screen, the state of SUM-A6 low and all lower order bits high is never reached. Line 192, HPE' — TEXT, Figure 6.6 The final two RAM ROW address assignments Line 192, HPE' + Lthru are VO and VI. These are not gated by the display Line 224, HPE' — HIRES, Figure 5.9 Line 224, HPE' + 1 thru mode, and they change at a high enough frequency Line 0, HPE' — TEXT, Figure 5.6 to satisfy the refresh requirement. The gated VA, VB, and VC inputs are static during TEXT/LORES HPE' occurs during the first video scanner state of scanning, and thus inappropriate as RAM ROW WTCP^" the screen, the address switching point for address inputs. iHlRES MIXED mode comes just at the end of the The most significant refresh bit is VI, and VI .lisplay on the right side. toggles back and forth every 32 horizontal scans. But VA, VB, and VC are not refresh bits, so for every IWHiESHlNG RAM IN THE APPLE lie state of VI and VO, all the lower refresh bits go through their counts eight straight times (once for each state of VA-VB-VC). This means that the ;.."^^i^^fresh ,W«t every ROWrequirement address beof 64K dynamic accessed RAMonceis at least maximum time between refresh states is normally ,eyery two milliseconds. To achieve refresh in the no more than 25 horizontal scans (32 - 7) or 1.59 / '■' ' ■ [^ 5-20 Understanding the Apple He into 48K of RAM, 4K of I/O, and 12K of ROM. In Table 53 Video Scanner Row Address terms of memory, this computer evolved into the Assignments. 64K RAM Apple II with 16K of RAM in Slot 0 and RAM Address Scanner Input an 80-column display card in Slot 3, then into the operationally similar Apple He with its added RAO HO capabilitiesof bank switching 64Kof auxiliary card RAl RAM. Apple He owners have thus inherited a com- HI H2 plex system of memory management, and it can be a RA2 RA3 SUM-A3 little puzzling, particularly for those new owners RA4 SUM-A4 who weren't around for the evolution. RA5 RA6 vo SUM-A5 MMU Soft Switches RA7 VI The bank switching and overall control of memory in the Apple He is a function of the MMU. The MMU milliseconds. At the end ofVBL, however, there are contains 13 programmable soft switches that are six extra horizonta! scans with VI and VO high. This set up by the controlling 6502 program. The state of means that there are sometinnes 31 horizontal scans these soft switches determines the overall eonfigua- (25 + 6) or 1.97 milliseconds between refresh states. tion of Apple memory— which devices respond to In all cases, the 2-millisecond maximum period which address ranges, Sixof the MMU soft switches hetween refresh states is satisfied. are concerned with bank switching between mother- As mentioned previously, some 64K dynamic board RAM and auxiliary card RAM. Four switches are concerned with determ ining whether high RAM RAM chips require only that A0--A6 of the RAM chips (RAT— RAl of the Apple lie RAM address or motherboard ROM responds to $D00O-$FFFF hus) be refreshed. Since RAO— RA7 of the Apple He addressing, and which bank of high RAM will are completely refreshed every two milliseconds, respond to $D000— $DFFF. The remaining three RAM in the Apple can be either the 128- or the switches determine whether motherboard ROM 2r)(i-cycle refresh tyi)e. or peripheral cards respond to $C100-$CFFF addressing. The soft switches are turned on and off by address MEMORY MANAGEMENT commands decoded from the address bus. Some of What device responds when the MPU accesses the switches simply have an off address and an on address $D000? The answer is all of the above. address, but control of INTC8R0M and the high Depending- on MMU soft switches and the periph- RAM configuration switches is more complex. In eral slot INHIBIT' line, it migrht be the Cl-DF addition to address bus control, all MMU soft ROM, motherboard high RAM bank 1, mother- switchesare reset (turned off) when asystem reset is board high RAM bank 2, auxiliary card high RAM detected. 'Ikble5.4 summarizes the address bus con- bank 1, auxiliary card high RAM bank 2, or adevice trol of the MMU soft switches and gives the control in any of the seven peripheral slots. Wow! Talk about situations resulting from system resets, your versatility . . . talk about your complexity. Some readers will be suprised by the "Rible 5.4 When more than one device is capable of respond- entries that show you can read the BANKl and ing to a single address range, the range and device HRAMRD soft switches at $C011 and $C012. Apple are said to be bank switched. Bank switching is doesn't document this capability, but I discovered it necessary when the address ranges of all the devices while investigating the operation of my Revision B that need to be addressed exceed the addressing range of the MPU, and when you hear of a 128K Apple lie (MMU marking 8310, 344-OOlO-B). An- RAM, 16K ROM computer with a 64K MPU, you other thing Apple does not document is the existence of the INTC8R0M soft switch. The peripheral slot can guess that there is going to be some bank switch- I/O STROBE' protocol is implemented for f C3XX ing involved. Yet the nature and extent of the bank and $C800—$CFFF motherboard ROM via this soft switch. switching in the Apple makes no sense unless viewed in historical terms. The original Apple II was designed at a time when 16K RAM chips and 2K ROM chips were state-of- Configuring High Memory <$DOOO-$FFFF) the-art and 48K seemed like a lot of RAM. The 64K Addresses $D000— $FFFF in the Apple He ar« addressing range of the 6502 was neatly divided up assigned primarily to ROM, but this 12K range can also be assigned to 16K of RAM. The capability of „:^5?i RAM and Memory Management 5-21 o PHERAL SLOTS PERI- ifulVV IN MP IN/OUT' I l/OSTRQRF' (/O SELECTS' DEVICE SELECTS KVBRO PEBIPH CUITS DECODE MUX SERIAL COXX'TOIOU CXXX MD IN/OUT' CIR- MMU ROMEf^f TIMING KBD' GEN RQMEIS|2' CASEN' \ MBD RAM .mm. KBD' CAS' RIW — Zl> O' ENB R/W'80 R/W lOU AUX RAM R/W COXX' ROM C1-DF ROM ROMENV -—^ EO-FF I R0MEN2'- I Figure 5.10 Distribution of MMU Dato Bus Management Signals. 5-22 Understanding the Apple lie Table 54 Address Bus Contrt)! of MMUSott Switches. CONDITION AFTER SOFT READ RESET' (OFF) OFF ADDRESS SWITCH ADDRESS ADDRESS ON FAGhia does not bank 80STORE w$cooo W$C001 switch RAM Read from motherboard RAMRD W$C002 W$C003 R$C013 R$C018* RAM Write to motherboard RAMWRT W$C004 W$C005 R$C014 RAM Slot response to INTCXROM W$C006 W$C007 R$C015 $C100-$CFFF Motherboard RAM ALTZP W$C008 W$C009 read/write R$C016 Motherboard ROM SL0TC3R0M W$COOA W$COOB R$C017 response to $C3XX Motherboard RAM PAGE2 $C054 $C055 read/write HIRES PAGE2 does not switch $C056 R$C01C* $C057 $2000-$3FFF A3 High RAM bank 2 BANKl** R$C01D* response to $DXXX $DO{)0-$FFFF read HRAMRD** (A1+A2)«(A1.A2)' R$C012 from ROM A1»A2+A1'»A2' 3 ' R$C011*** None Reset PRE WRI TE* * A AO'+(R/W')' None $DOO0— $FFFF write to HRAMWRT' ** PRE -WRITE. R/W'.AO AO • R/W' None high RAM INTC8R0M Slot response to $C3XX • SL0TC3R0M' $CFFF $C800-$CFFF NOTES: R Preceeding address indicates read access only. W Preceeding- address indicates write access only. ' * 80STORE, PAGE2. and HIRES are mechanized AOidentical! y in the MMU tind lOU. The MMU passes the state of 80STORE to MD7 when $C018 is read, ft switch before it can reset HRAMWRT'. •For a discussion of the 16K RAM card, refer to Chapter 5 of PRE-WRITE is set by odd read access in the Uvdemlaiidhig fhe Apple U by Jim Sather, Quality Software, *C08X range. It is reset by even read access 1983. 5-24 Understanding the Apple lie A second difference is that the 16K RAM card is until an even access is made in the $C08X range. not automatically disabled when another peripheral This means there is a feature of RAM card control not documented by Apple: write access to an odd card pulls the INHIBIT' line low, A particularly nettlesome associated fact is that the 16K RAM card address in the $C08X range controls HRAMRD will not release the $F800— $FFFF address range without affecting the state of HRAMWRT'. under any circumstances, even when its RAM is The high RAM control characteristic s are sum- marized in Table 5.5. There are two address disabled for reading and writing.* When RAM is disabled, a ROM on the RAM card hogs this critical commands possible for every function. The pro- gramming convention is to use addresses $C080— range. When INHIBIT' is low in the Apple He, all motherboard RAM, auxiliary card RAM, and $C083 and $C088-$C08B. mother board ROM is disabled, including high RAM. The only address range at which RAM is never The data bus management signals with which accessed in the Apple He is the 4K range, $CXXX. When bank 1 of high RAM is being accessed, the the MMU configures high memory are CASEN', MMU converts the $DXXX address on the address EN80', ROMENl', and R0MEN2'. All of these bus to a $CXXX address on the multiplexed RAM signals are gated by INHIBIT', so no matter what address bus. $DXXX is changed to $CXXX by the configuration of high memory, any peripheral changing A12 from high to low, so the A12 input to card can steal $D000— $FFFF by pulling INHIBIT' low. RA4/C0LUMN is forced low in the MMU when BANKl is set and an address in the $DXXX range is on the address bus. The equation for the COLUMN Switching iaelween Motherboard input to RA4 is therefore end Auxiliary Card 12AM Switching between memory banks presents a A12« (BANKl. DXXX)'. problem if the program doing the switching resides Though program control of high RAM in the in one of the memory banks being switched. The Apple lie is identical to that of the Slot 0 16K RAM problem is that when the switching command is card in the Apple II, there are some operational executed, the MPU starts fetching the program differences. First, the 16K RAM card does not from the newly active memory bank, but the pro- respond to system resets. It is set to read disable, gram that is supposed to be executed resides in the write enable bank 2 at power up, and from that point can only be reconfigured by program control. High *Th is is only true of the 16K RAM card manufactured by Apple RAM in the Apple lie is set to read disable, write Computer, Inc., and of RAM cards which are very close imita- enable bank 2 by any system reset, not just the one tions ofApple's card. Some alternate source 16K RAM cardswill release the $F800— $FFFF range when RAM on the card is that occurs at power up. disabled. Table 5^ High RAM Address Bus Commands. BANK 2 BANKl ACTION $C080 $C088 WRTCOUNT = 0*, WRITE DISABLE READ ENABLE $C084 $C08C R$C081 R$C089 WRTCOUNT = WRTCOUNT + 1* READ DISABLE R$C085 R$C08D W$C081 W$C089 WRTCOUNT = 0* READ DISABLE WIC085 W$C08D $C082 WRTCOUNT = 0*, WRITE DISABLE READ DISABLE $C08A $C086 $C08E R$C083 R$C08B WRTCOUNT = WRTCOUNT + 1* READ ENABLE R$C087 R$C08F W$C083 W$C08B WRTCOUNT = 0* •W READ ENABLE W$C087 W$C08Friti ig to hijfh RAM is enabled when WRTCOUNT reaches 2. ,. «lpt ^f^^: RAM and Memory Management 5-25 previously active memory bank. One way to get and auxiliary card RAM for reading and writing in around this is to prearrange the contents of the the $400-$7FF range. If 80STORE is set and newly active bank so that there is a program at the HIRES is set, then PAGE2 switches beween moth- switch point which is designed to accept flow from erboard RAM and auxiliary card RAM for reading the previously active bank. This is not an insur- and writing in the $400— $7FF and $2000— $3FFF mountable task for the computer programmer, but ranges. PAGE2 set selects auxiliary card RAM, it is a nuisance. Abetter solution, when possible, is to and PAGE2 reset selects motherboard RAM. If design the application so that the switching pro- 80STORE is reset, then RAMRD and RAMWRT gram resides outside of the memory beingswitched. will bank switch the $400— $7FF and $2000— Apple went to some lengths to ease the pro- $3FFF ranges along with the rest of the $200— grammer's task in bank switching between moth- $BFFF range. erboard RAM and auxiliary card RAM in the Apple 80STORE, PAGE2. and HIRES are mechanized He. For one thing, they provided a transfer routine identically in the MMU and the lOU, They are used in ROM which transfers program control between in the MMU for bank switching display memory as motherboard resident and auxiliary card resident described here. They are used in the lOU to control routines. Therefore, any time high RAM is disabled the display mode of the Apple He. As noted pre- for reading, routines residing outside of the memory viously, when 80STORE is set, the display mode being switched are available for switching between control functions of PAGE2 are disabled. motherboard RAM and auxiliary card RAM. Use of ALTZP switches the $0— $1FF range and, if the firmware transfer routine is described on pages high RAM is enabled, the $D000— $FFFF range 29-31 of the Apple II Extended 80-Column Text between motherboard RAM and auxiliary card Card Supplement for lie Only and on pages 76—79 RAM. ALTZP set selects auxiliary card RAM, and of the Apple II Reference Manual for He Only. ALTZP reset selects motherboard RAM. Another thing that Apple did to ease the pro- The overall scheme represented by these soft grammer's bank switching problems was to divide switch capabilities is logical. High RAM is switched RAM into several separately switched groups so that programs residing in one area of RAM could separately from the main body of RAM because switch other areas of RAM. Instead of one soft these two RAM groups are addressed at separate switch which switches all of RAM access between non-overlapping address ranges. Memory pages 0 the motherboard and the auxiliary card, there are and 1 of RAM receive special treatment because of six MMU soft switches which switch various opera- their special 6502 functions. Display scanned mem- tional areas of RAM. The sense of the switches is ory receives special treatment to ease the task of generally such that when a switch is set (on), auxil- programming DOUBLE-RES displays. Some pro- iary card RAM is enabled, and when the switch is gramming scenarios should illustrate the pros and reset (off), motherboard RAM is enabled. The func- cons of the way RAM switching is divided. tions ofthese six switches are graphically depicted scenario #1: A machine language program resides in Figure 5.12 and briefly described here. Refer to in high RAM, motherboard ROM, or peripheral T^bie 5.4 for the control addresses of the soft card high memory, and uses both motherboard and switches. auxiliary card low RAM for data storage. RAMRD and RAMWRT switch the $200- $BFFF range between motherboard RAM and aux- The program can easily switch between mother- iliary card RAM. RAMRD set enables auxiliary card board and auxiliary card RAM via RAMRD and memory for reading, and RAMWRT set enables RAMWRT. The program's critical zero page point- auxiliary card memory for writing. If 80STORE is ers and subroutine return link information on f_*' RAMRD and RAMWRT do not affect $400- the stack are not switched because RAMRD and 1 *»' ^""^ *^ 80STORE and HIRES are both set, RAM WRT do not switch $0-$lFF. Pages 0 and I of KAMRD and RAMWRT do not affect $400-$7FF RAM usually hold information critical to the pro- or $2000-$3FFF. gram being executed, even if the program resides in 80STORE, PAGE2, and HIRES bank switch the ROM. All programs that bank switch RAM need to l^^^y display pages, $400-$7FF and $2000- take special cognizance of these two memory pages, I^' ^^^w^n motherboard RAM and auxiliary and the Apple He design allows the programmer to T 5^^" " 80STORE is set and HIRES is reset, do so because $0— $1FF switching is separate from /^ PAGE2 switches between motherboard RAM the main body of RAM in the Apple. ■•^ai,.-. 5-26 Understanding the Apple He 80ST0RE. HIRES (W$C001,$C057) ORO) C00E. (W$TOR HIR6) 1,$C05 ES' (W STOO 80SC E' 80S SFFFF $FFFF $FFFF SEOOO SEOOO SEOOO $0000 $0000 SDOOO SBFFF SBFFF SBFFF $3FFF $2000 $400-S7FF $400-$7FF $0-S1FF- $0-$1FF $0-$1FF LEGEND RAMRD' & RAMWRT'= Motherboard RAM (W$C002,W$C004) RAMRD & RAMWRT = Auxiliary RAM (W$C003,WSC005) [■x:>::::;:::i>:;>:v::;::i ALTZP'= Motherboard RAM (WSC008) ^'■■■■■■■■■■■■■■v-'l ALrZP = Auxiliary RAM (W$b009) ^HBH ■■^^H PAGE2'= Motherboard RAM ($C054) PAGE2 = Auxiliary RAM ($C055} Figure 5.1 2 Motherboard/ Auxiliary Card RAM Bonk Swilched Address Ranges. RAM and Memory Management 5-27 Example: The situation becomes more difficult if the pro- ORG $D000 HIGH RAM RESIDENT PKX3RAM gram needs to maintain a primary and a secondary DOUBLE-RES display, and switch between them STft $C003 SET RAMRD STA $0004 RESET RAMWRT via PAGE2 with 80STORE reset. The problem here im $8000 FETCH DATA FROM AUX $8000 is that MPU access to the secondary display areas STA $8000 STORE DATA AT MRBRD-$8000 ($800-$BFF and $4000-$3FFF) is switchable only via RAMRD and RAMWRT. The task can be scenario #2: A machine language program resides accomplished by storing the controlling program in tower motherboard RAM, and uses motherboard redundantly in motherboard and auxiliary card and auxiliary card high RAM for data storage. The RAM, but things will be a lot easier if this sort of program is initialized and normally runs with program resides in high RAM. motherboard memory pages 0 and 1 enabled. Example: This situation is not particularly well supported ORG $1000 LCW RAM RESIDENT PROGRAM by the Apple He design. The program can enable STA $C001 SET 80STORE auxiliary card high RAM via ALTZP, HRAMRD, STA $C055 PAGE2 = AUX = EVEN TEXT POSITIOsT and HRAMWRT', but when auxiliary card high RAM is enabled, the program loses actfess to its OTA (BASL),Y STORE ASCII TO TEXT MAP Page 0 pointers and subroutine return link informa- tion. The program must therefore make its access to scenario #4: A programmer wants to utilize auxil- auxiliary card high RAM, then reset ALTZP before iary card memory for data storage in his Applesoft accessing pages 0 and 1. Alternately, it can transfer or Integer BASIC application. critical page 0 and 1 information from motherboard RAM to auxiliary card RAM before setting ALTZP, The programmer is, as they say in the Navy, S-O-L and it can transfer critical page 0 and 1 information (Surely Out of Luck). BASIC variable structuredoes from auxiliary card RAM to motherboard RAM not support the fixed address access to memory re- before resetting ALTZP. quired by bank switching. Additionally, the inter- Example: preter inhigh memory, the program in low RAM, the variables in low RAM, and the page 0 and 1 ORG $1000 1£M RAM RESIDENT PROGRAM values tend to get lost when you enablethe auxil iary STA $C009 SET ALTZP card RAM. BASIC programs can manipulate 80- LDX $BA WHOOPS! I NEEDED A MOTHER- STORE, HIRES, and PAGE2 to access $400-$7FF BOARD POINTER and $2000-$3FFF of auxiliary card RAM via STA ($44), Y OUCHl MY INDIRECTION IS PEEK, POKE, HPLOT, PLOT, HLIN, VLINE, GUMMED UP and PRINT commands. Outside of the 80STORE RTS I WANT MY MOTHER areas, it is most likely that any BASIC access to scenario #3: A machine language program resides auxiliary memory would be through CALLs to in low RAM and maintains an 80-column text machine language routines. display. Example: The text map is stored alternately in auxiliary 10 POKE -16383,0 : REM SET 80STORE card RAM and motherboard RAM at addresses 20 PCKE -16299,0 : REM PAGE2 = AUK = $400— $7F7, so the program needs to make regular EVEN access to both the auxiliary card and the mother- 30 POKE 1024,193 board without disrupting program flow. This is TOP LEFT done simply by setting 80STORE , resetting H IRES, and using PAGE2 to switch MPU access back and torth between auxiliary card RAM and mother- The data bus management signals with which the board RAM. Program flow outside of the $400- MMU switches between motherboard and auxiliary m fk j^"^^ '^ "*^* affected in any way. The identical card RAM are CASEN' and EN80'. CASEN' is low method IS used for maintaining an 80-bIock LORES when the MPU is accessing motherboard RAM, and Q'splay. A 560-point HIRES display can be sim- EN80' is low when the MPU is accessing auxiliary ilarly maintained by setting 80STORE and HIRES card RAM. Both CASEN' and EN80' are gated by ana using PAGE2 to switch $2000-$3FFF INHIBIT' so any peripheral card can steal RAM access addressing from motherboard or auxiliary card ^m^ ^"'^iliary card RAM and motherboard RAM by pulling INHIBIT' low. '**<- . 5-28 Underetanding the Apple lie From that point, $C800— $CFFF will stay assignee Configuring the I/O Range C$COOO-$CFFF) to motherboard ROM until an access is made U The 4K $C000— $CFPF range in the Apple lie is $CFFF or until the MMU detects a system reset assigned to I/O. Motherboard ROM, however, can The circuit mechanization which fits this functionij steal $C100— $CFFF from I/O and it does so on reality is that of an unreadable soft switch setbj a regular basis. Program control of response to access to $C3XX with SL0TC3R0M reset, andresel $C100— $CFFF is via three MMU soft switches, by access to $CFFF or an MMU reset. INTCXROM*, SLOTC3ROM, and INTCSROM. As it is with the $C3XX range, joint control of the The $C100— $CFFF range of I/O includes the $C800— $CFFF range is an ORfunction if INIfernal peripheral slot I/O SELECT' and I/O STROBE' is considered true and SLOT is considered false. By signals. These signals are generally used to en- this it is meant that if INTCXROM OR SLOT- able peripheral slot ROM, and INTCXROM, C3R0M is configured for internal response, then SL0TC3R0M, and INTC8R0M are thought of as switching between slot ROM and internal (mother- access to $C3XX results in ROMENl' low (active) board) ROM. These soft switches have no effect on and Slot 3 I/O SELECT' high (inactive). In the same vein, if INTCXROM OR INTC8R0M is configured the $COXX range. There is no hardware or soft- ware means of stealing $COXX from I/O in the for internal response, then access to $C800— $CFFF Apple lie. A corollary to this fact is that the results in ROMENl' low (active) and I/O STROBE' DEVICE SELECTS of the peripheral slots cannot high (inactive). The INTC8R0M mechanization follows protocol be inhibited in the Apple lie. In particular, periph- for a Slot 3 peripheral card that responds to I/O eral cards that respond to DEVICE SELECT', but not I/O SELECT' or I/O STROBE', can be operated SELECT' and I/O STROBE'. This is consistent in Slot 3, even when a RAM/80-column card is with the Apple He philosophy of emulating an installed in the auxiliary slot. Apple II with 80-column card installed in Slot 3. INTCXROM switches the $C100— $CFFF range More information about the I/O STROBE' protocol between internal and slot ROM, and SL0TC3ROM is given in Chapter 7. switches the $C3XX range. Both INTCXROM INTCXROM, SL0TC3R0M, and INTC8R0M al- and SL0TC3R0M affect $C3XX (the Slot 3 I/O low MPU access to the lower half of the Cl— DF ROM. INTCXROM is used to gain access to a SELECT' range), and ifeithersoftswitch is set to in- number of routines including the extended monitor ternal, the motherboard CI— DF ROM will respond to $C3XX access. The following truth table shows routines and built-in diagnostic routines. SLOT- the control status resulting from the four possible C3R0M and INTC8R0M are used to gain access to combined states of INTCXROM and SL0TC3R0M. the 80-column firmware. Like all MMU soft switches, INTCXROM, SLOT- $C100-$C2FF C3R0M, and INTC8R0M are reset when a system INTCXROM SL0TC3R0M reset is detected. This enables all I/O decoding $C400-SCFFF $C300-SC3FF reset reset slot internal reset set slot slot except for Slot 3 I/O SELECT' ($C3XX). After the set reset internal hardware reset, the motherboard firmware reset internal set internal internal handler sets SL0TC3R0M if no RAM card is set installed in the auxiliary slot, and resets SLOT- You will find no reference to the INTC8R0M soft C3R0M if a RAM card is installed in the auxiliary switch in Apple literature. You will find, how- slot. ever, that it is possible for motherboard ROM to The data bus man agement s ignal s with which the steal response to $C800-$CFFF without setting MMU switches between internal or slot response INTCXROM. The ?C800-$CFFF range is assigned to $C100— $CFFF are CXXX and ROMENl'. '■.:l. to motherboard ROM (INTernal) anytime SLOT- ROMENl' is gated by INHIBIT', so peripheral C3R0M is reset and an access is made to $C3XX. cards can steal $C100— $CFFF by disabling slot response and bringing INHIBIT' low. •Apple refers to INTCXROM as SLOTCXROM, but slot ROM is disabled when the "CX" switch is set. The "CX" switch can be KBD' and MD IN/OUT' correctly referred to as the SLOTCXROM' switch, but I feel that INTCXROM is more descriptive. There appears to have been There are two MMU data bus management sig- some miscommunication at Apple about the operation of this nals which have nothing to do with RAM. These are switch. Operational descriptions on pages 133 and 214 of KBD', the keyboard enable signal, and MD IN/ the Apple II Reference Manml for tie Only are demonstrably Inaccurate . OUT' the peripheral slot bus driver direction «»' trol signal. ii W RAM and Memory Management 5-29 The MMU pulls KBD' low during PHASE 0 of a MMU soft switches, Figure 5.13b shows the logical read access to the $C000— $C01F range. This unin- generation of data bus management signals from hibitable action causes the contents of the keyboard address decoded signals, the states of the MMU soft ROM to be placed on the data bus for reading by the switches, and the R/W, DMA', and INHIBIT' MPU. Normal programming convention is to read inputs to the MMU. These drawings are meant only the keyboard input at $C000, and the fact that you to show MMU functions, not correct implementa- can read it at $C01X is definitely not documented by tion details, I drew these figures to clearly illustrate Apple. Nevertheless, with the MMU currently being MMU operation and have no way of knowing such manufactured, the KBD' signal responds to read details as the exact arrangement of logic gates. access at $CO0O— $C01F. The MMU drawings summarize points about MD IN/OUT' is normally low, and this causes the MMU operation that are made in Understanding the peripheral slot bidirectional driver to normally Apple He, and they serve as an MMU quick refer- present a high impedance to the data bus, MD ence for people who tike diagrams like this (I do). IN/OUT' goes high during PHASE 0 of Some explanations and discussion points follow. 1. Any read to $C020— $COFF {enables MPU or 1. RESET' is not an input to the MMU because DMA device to read $C06X serial inputs, DE- there is a shortage of available pins created by VICE SELECT' gated peripheral card inputs, full connection to the address bus and the mul- or outlandish peripheral cards which respond tiplexed RAM address bus. The MMU detects with data to $C020— $C08F addressing). system resets from three Page 1 accesses fol- 2. Any read to $C100— $CFFF with slot response lowed by$FPFC on the address bus. The MMU enabled by INTCXROM, SL0TC3R0M, and will wrongly detect a system reset if a Page 1 INTC8R0M (enables MPU or DMA device to resident program causes the MPU to access read I/O SELECT' and I/O STROBE' gated $FFFC, perform a"JMP($FFFC)", or vector to peripheral card inputs). SFFFC via an RTS or RTI instruction. 3. Any read with INHIBIT' low (enables MPU or 2. There appears to be a window during which the DMA device to read from peripheral card address bus is monitored for commands which memory when motherboard and auxiliary card determine soft switch states. If a soft switch memory are inhibited). command is held valid on the address bus for 4. Any write with DMA' low (enables DMA device about 40 nanoseconds or more during the win- to write data to devices on the data bus). dow, the affected soft switch will respond to the command. As well as I can determine, this win- TheMD IN/OUT' control may seem complex, but when you examine the requirements of the Apple dow is PHASEO • (Q3 + HAS") which is all but the last 14M period of PHASE 0. The 6502 He memory map, MD IN/OUT' is seen to correctly address valid period completely overlaps this control the direction of data flow to and from the window. peripheral slots and serial input multiplexor. The 3. When the MPU reads the state of an MMU soft one unusual point about MD IN/OUT' mechaniza- switch, the MD7 enable gate appears to be tion isthat read access to $C000— $C01F with INHIBIT' low causes MD IN/OUT' to go high, even PHASEO + PHASED' • Q3 • RAS' which is though the keyboard input is not deactivated by PHASE 0 and the first 14M period of the follow- INHIBIT'. As a result, read access to $C000— ing PHASE 1. ?C01F with INHIBIT' low will cause the peripheral 4. The four high-RAM configuration soft switches data bus driver to compete with (and overwhelm) are programmed identically to the four config- the keyboard ROM and lOU for control of the data uration flip-flops on a 16K RAM card. 5. After an MMU reset, the MPU will read all soft bus. This is not a great problem for peripheral card switches except BANKl as zero. Figure 5.13a designers, but it does mean that inhibiting periph- shows a BANKl soft switch whose inverted eral cards must bring INHIBIT' high during read access to $C000-$C01F if the MPU is to read the state is readable by the MPU. A functional keyboard. equivalent would be a BANK2 soft switch which is set when an MMU reset occurs and whose non- inverted state is read by the MPU. 'he MMU Functional Diagram The depiction chosen for Figure 5.13a is closer Figures5.13a and 5.13b are a functional diagram to the 16K RAM card hardware, and it follows or the MMU. Figure 5.13a shows address decoding, the general MMU rule of resetting soft switches reset detection. MPU address multiplexing, and the when a system reset occurs. 5^ Understanding the Apple lie "a. -5V MMU reset i( three Paget E4 ►MMU .|.0 TWO BIT COUNTER accesses are followea by 5V- CK SFFFC on the address bus. FFFC (39) .I'O- _--.ir TI 03 COUNT ENABLE OVERFLOW CLOCKED □3- 01XX — 1— RAS'- CLEAR ■"^ TO MMU GATES t/tm RESET ^ XXXX SIGNALS TO SHEET 2 RAS' (4 21 < PRE-WRITE Figure 5.13a The MMU (1 o< 2). RAS' selects between ROW and COLUMN ad- dres ing atthe MPU address multiplexor. The All memory enabling signals— ROMENl', tri-state enable window for the MMU multi- 10 R0MEN2', CASEN', and EN80'-are gated by INHIBIT' from the peripheral slots. plexed RAM address output appears to be CASEN' and EN80' are mutually exclusive. PH ASEO' • Q3' . RAS' + PHASEO* Q3 which is the last 14M period of PHASE 1 and the first When RAM is being accessed, either CASEN' four 14M periods of PHASE 0. 11 or EN80', but not both, will be activated. RA4 COLUMN addressing has special logic for KBD'theis expecte RCOOO— gated dby RC RCOIFX. rather than just OO ^ switching between bank 1 and bank 2 of high RAM. 12. MD IN/OUT' goes high during any INHIBIT 8. low readandrather than the expected ROOOO— ROMENl', R0MEN2', EN80', KBD', and MD RBFFF RC020— RFFFF. IN/OUT' are all gated by PHASE 0. CASEN' is not gated by PHASE 0 in the MMU, but it is 13. Write access to $C100— $CFFF with the ad- gated by PHASE 0 in the timing HAL. dressed location configured for motherboard ROM response causes ROMENl' to fall. As a RAM and Memory Management 5^1 16 C020-C0FF- (7.6) DMA^ (7,6) INHIBI- r, 15 ■ INHIBIT' E4 MMU DMA' 22 :0 R/W- -MD IN/OUT' =I> (7,6) -CXXX DMA'- C100-CFFF INHIBIT' ■ C100-CFFF COXX INTCXROM C100-CFFF (SLOT) 24_ C3XX SL0TC3R0M (7,1) fi/W'■ '^C INTC8f!0M LR -ROMENT T) C100-CFFF[im S 0 RDXX HRAM -C. PDX- 19 t E 20 (61) C800-CFFF ■1.0 F- — MMUCFF *0 RESET FROM SHEET 1 ALTZP INHIBIT' 18 EOOO-FFFF SWITCHING R/W roX> HRAMWRT DOOO-FFFF : -R0MEN2' HRAMRD — C R/W ■I'D (6,1) RC000-RC01 INHIBIT' ■I' a> HRAMRD- (5,2) -KBD' ALTZP- PAGE2 17 -EN80' PAGE 2 SWITCHING INHIBIT- aoSTORE - O-IOO-O/FF 23 ^>'J> RAMRO/WfiT SWITCHING INHIBIT' 1 y (391 -CASEN' 0200- BFFF- RAMWRT R/W RAMRD NOTE: Lu Address range signals decoded from address bus. Figure 5.13b The MMU (2 of 2). 5^2 Understanding the Apple He PHASE 1. It has, however, been indicated to me result, this programming action will cause the that Apple only tests the MMU to perform correctly CI— DF ROM to compete with the MPU for with worst ease performance of the 6502 A. There- control of the data bus. This is the only time fore, the only way a DMA device can be guaranteed ROMENl' or R0MEN2' is activated by write to operate in the Apple He is if its address is set up on access. the address bus no later than 210 nanoseconds after The data bus management signals are logically PHASE 0 falls (5 nsec LS02 delay + 65 nsec 6502 mechanized to perform the memory management PHASE 2 delay + 140 nsec 6502 address setup). This functions described in this chapter. Figure 5.13b is u nr eal istical ly con servati ve si nee an M MU would shows this logic for those readers comfortable with have to have a 349-nanoseeond address bus to RAM logic symbols. Tables 5.6 and 5.7 contain the same address bus delay to perform this poorly, information for those readers more comfortable with cause and effect tables. Table 5.6 shows when the signals that gate data to the data bus become RAM TIMING IN THE APPLE lie active, and becomes Table 5.7 shows when MD IN/OUT' active. Most aspects of RAM timing have already been covered in various other related discussions, The intention here is to reinforce the timing details of MMU Signal Propagation Deiay basic RAM access. The MMU and lOU are MOS ICs like the 6502, Figure 5.14 shows some basic details of video RAM, and ROM chips. These MOS ICs perform scanner read and 6502 read/write access to mother- very complex and extensive logic functions, but board RAM. The RAM access is controlled by the compared to the bipolar ICs like TTL chips and the timingHAL, MOS ICsare slow. Whereas you might RAS' and CAS' timing signals, and these fix the RAM access rate at 2 MHz. Even though 200- expect 5^25 nanosecond signal propagation delay nanosecond RAM can be accessed faster than this, in an LSTTL chip, you would likely expect 30— no DMA device could access Apple lie motherboard 125 nanosecond propagation delays in MOS ICs. RAM any faster unless higher frequency substitutes These approximations are admittedly vague, but you should get the idea that the speed of the Apple is for RAS' and CAS' were injected from an auxiliary limited by the MOS chips, not the TTL chips. card. RAS' strobes the ROW address to the RAM The MMU signal delay specifications have not chips, and CAS' strobes the COLUMN address to been released by Apple Computer Inc. If we could the RAM chips and initiates the data transfer. see them, they would probably show minimum and Most of the RAM timing is straightforward. maximum timing durations referenced to rising Write data from the 6502 is set up well before CAS' falls during PHASE 0. Read data becomes valid and falling edges of PHASE 0, Q3, RAS', and the well before PHASE 0 rises to latch video data, and address bus. I have observed the MMU signal delays in my Apple lie with an oscilloscope, and I found well before PHASE 2 falls to clock the transfer of them generally to be 40—100 nanoseconds. Asa rule read data to the 6502. One thing that is not straight- of thumb, the MMU signal delays are comparable in forward isthe RAM data hold time after CAS' ris^ width to one I4M period. during MPU read access to RAM. It is highly possi- One MMU specification I think Apple should pub- ble that the RAM chip will not hold the data past the lish isthe maximum delay of address information falling edge of PHASE 2, but the data transfer is from the address bus input to the multiplexed accomplished anyway because of the slow bleed off address bus output. This specification determines of data from the floating data bus. The data bus and the time by which DMA devices must set up their all of its extensions hold datafor a long time when address if RAS' falling is to properly strobe the they float. Insuring the correct transfer of RAM ROW address to RAM and the lOU. This delay is read data to the 6502 is just one example of the long about 82 nanoseconds in my Apple He.* My feeling bleed off time determining Apple lie operational characteristics. is that DMA devices are probably safe if they set up the address bus at or before RAS' rises during In the write cycle, the video scanner makes its read access to RAM during PHASE 1 just as in the read cycle. Nothing interrupts the scanner access to •I measured this by grounding the READY and DMA' lines and injecting a variable width pulse to AO of the address bus from a RAM in an unmodified Apple, However, the video pulse generator triggered by WNDW. data on the data bus is not routed to the peripheral cards during PHASE 1 of write cycles. RAM and Memofy Management 5-33 Toble 5^ MMU Data Bus Communication Enable Signals. DATA nm MPOTS GRTINQ SIGNALS H 8 1 S I P I RHR0 NLNHN R R RARASHPATTTAH C 0 0 AMAMTIALCCCSI A E M M C RMWMWORGTX38EB S N E E X K ADDRESS /RRRRREEZRRR I E 8 N N X B RANGE W'DTDT'ES 2 PMMM0T' N' 0- 1' 2' X D' . 0 . . . . H $0000-$01EF L H H H L H * ♦ ■ . 1 . . . H H H L H H L H R 13 . . . . . H L H H H L H R 1 . . . . H H H L H H L H $0200-$03EF, W . 0 . . . . H L H H H L H $0800-$lFFF, W . 1 . . . H H H L H H L H S4000-$Bt'i'l;' 0 SEE TART.K A $0400-$07EF 1 . (3 . . . . H L H H H L H 1 L . . . H H H L H H L H ?2000-$3FEF 0 SEE TART.K A • 13 . SEE TABLE A 1 JL 0 . . . H L H H H L H 1 JL i . . H H H L H H L H R * H H H H H L $aW0-$C0iF W .... H H H H H H $C020-$C0FF . H H H H H H ?C100-$C2FF, 0 . . . . H H H H H H $C400-$C7FF 1 . , H H H H L H L H 0 1... H H H H H H $C,'W)0-$C3EF 1 . . H H H H L H L H , 0 . H H H H L H L H ?Cfl00-$CEW 3.0.. H H H H H H J. . . H H H H L H L H . 1 H H H H L H L H .5D000-$DFEF R 0 . . . H H H H L H L H R 0 . . . H H H H H L L H ^E000-SFPFF R 1 . . . . H ¥iAM0-?EFFF L H H H L H R 0 . . . H H H L H H L H 1. 1 . W k. . . . H L H H H L H W 1 , 0 . . . H H H L H H L H ** • * H H H H L H . . ■1 •. . . . . I^SGQID: R - REftD NOTES W - WRITE * KBD' is PHASE 0 gated. QCXX is not. 1 - SOFT SWITCH SET ** All ocntoinations not shewn result 0 - SOFT SWITCH RESET in inactive oondition (H H H H L H)J H - SIGNAL HIGH Boldfaced signals are active. _ L - SIGNAL LOW 5^34 Understanding the Apple He Table 5.7 Activation of MD IN/OUT'. INT SLOT INT PHS ADDRESS RANGE CXRM C3RM C8RM 0 R/W MD IN/OUT' W L - - - - H H $0000— $FFFF - - - - R L H H $0000— $FFFF D-MA' - - - - H $C020-$C0FF R H R - - INH' 0 - - H H $C100— $C2FF, ¥C400-$C7FF - - - R 0 1 H H $C300-$C3FF - - - $C800-$CFFF ^ 0 0 H H LEGEND: R READ NOTE: All combinations not s hown result in MD W WRITE IN/OUT' low. Direction is into the data bus | 1 SOFT SWITCH SET 0 SOFT SWITCH RESET when MD IN/OUT' is hig-h. H SIGNAL HIGH L SIGNAL LOW - NO EFFECT The order of important events in Figure 5.14 is: to the RAM address bus after MMU propaga- tion delay. This does not interfere with the pre- L HAS' rises near the end of PHASE 0. After lOU vious RAM cycle because this new address is not propagation delay, this enables the video ROW address to the multiplexed RAM address bus. clocked to RAM until RAS' falls. The delay depends on the lOU, but the RAM 8. PHASE 0 and CAS' rise simultaneously. PHASE 0 rising latches the video data in the ROW address must always be valid before RAS' video latch, and PHASE 0 high allows RAM falls. 2. PHASE 2 falls, clocking- the data transfer of the R/W' to fall if this is an MPU write cycle. CAS' previous 6502 machine cycle. rising causes the RAM chips to bring their data output lines to high impedance after a delay. 3. RAS' falls and clocks the video ROW address to This delay will not exceed 50 nanoseconds if RAM. RAS' low enables the video COLUMN address to the RAM address bus after lOU 200-nanoseeond RAM chips are installed. propagation delay. This delay must be short 9. During PHASE 0. the MPU addresses RAM in enough that the COLUMN address is valid the same way the video scanner did during before CAS' falls. PHASE 1, with RAS' selecting ROW or COL- 4. Early during PHASE 1, the 6502 address and UMN, and RAS' and CAS' clocking the address R/W' become valid. The address will have no to RAM. The only difference is that the MPU effect on RAM until the MMU takes control of RAM address is developed in the MMU instead the RAM address bus after RAS' rises. The of the lOU. Just as in the scanner access, RAM data from the MPU access becomes valid on the R/W' line will have no effect on RAM until data bus well before the data is transferred, PHASE 0 rises because RAM R/W' is forced high during PHASE L 10. During write cycles, the 6502 write data must 5. CAS' falls, clockingthe video COLUMN address be valid before CAS' falls during PHASE 0. to RAM and initiating the transfer of video data The write data stays valid until after PHASE 2 from RAM to the data bus. falls. The Apple write cycle is what is referred 6. Video data becomes valid at the output of RAM. to in RAM literature as an early write cycle (as The time at which this occurs will depend upon opposed to a read/write cycle). R/W' falls before the speed of the RAM chips installed in the CAS', and write data must be valid at the RAM Apple He. Assuming 200-nanosecond RAM is input before CAS' falls. installed, the video data will become valid on the data bus no more than 135 nanoseconds after 11. PHASE 0 falls simultaneously with CAS' ris- ing. Ifthis is a write cycle, RAM R/W' begins to CAS' falls. This is well before PHASE 0 rises. rise but takes a long time because the voltage is 7. RAS' rises and enables the MPU ROW address being pulled up by a IK resistor. If this is a read -ran RAM and Memory Management 5^ cycle, CAS' rising causes the RAM chips to Figure 5.15 shows some basic details of video bring their data outputs to high impedance scanner read and 6502 read/write access to a 64K after a delay of no more than 50 nanoseconds. auxiliary RAM card. The responseof auxiliary card The data bus may float before PHASE 2 falls, RAM to its RAS' and CAS' inputs is identical to that but the data from RAM will stay valid on the of motherboard RAM, but timing details are differ- floating data bus. ent because Q3 is the CAS' input to the RAM chips 12. RAM read data is clocked to the MPU by on the auxiliary card, and because of the presence of PHASE 2 falling. the bidirectional data bus driver. ^*% 4 5^36 Understanding the Apple lie is still valid well before PHASE 0 rises. The The development of the multiplexed RAM address auxiliary card video data is not passed to the is the same whether motherboard RAM or auxiliary card RAM is accessed. Motherboard RAM and aux- data bus at this time because EN80' is high, dis- abling the auxiliary card bidirectional driver. iliary card RAM always have the identical address applied to their address inputs. The only difference 5. PHASE 0 and Q3 rise simultaneously. PHASE 0 rising clocks the video data to the auxiliary in addressing detail is that CAS' falling clocks the card and motherboard latches. The auxiliary COLUMN address to motherboard RAM while Q3 falling clocks the COLUMN address to auxiliary card RAM data chips bring their data outputs card RAM. to high impedance no more than 50 nanosec- When an auxiliary card is installed, the video onds after Q3 rises if 200-nanosecond RAM is scanner simultaneously accesses the current scan installed. address in motherboard and auxilary card RAM, 6. PHASE 0 high causes the MMU to bring EN80' Data from this access is saved in the motherboard low after propagation delay. EN80' in turn and auxiliary card videodata latches when PHASE causes R/W'80, the auxiliary card RAM chip 0 rises. Video scanner access to motherboard and read/write control, to go low if this is an MPU auxiliary card RAM occurs every PHASE 1, re- write cycle. EN80' also enables the auxiliary gardles ofwhich device the MPU accesses during card bidirectiona l driver to pass data between PHASE 0. the auxiliary card and thedata bus in the direc- The order of important events in Figure 5. 15 is as tion determined by R/W'. The immediate effect follows: of th is is to pass auxiliary data from the floating auxiliary data bus to the data bus in a read 1. PHASE 2 falls, clocking the data transfer of the cycle, and to pass motherboard video data from previous 6502 cycle. the floating data bus to the auxiliary data bus 2. During PHASE 1, the video scanner ROW and during a write cycle. COLUMN addresses are developed in theMMU 7. During PHASE 0. no matter what Apple He as was described in the motherboard RAM tim- device is being accessed, the address bus is mul- ing section. RAS' falling clocks the video ROW ti plexed onto the RAM address bus by the MMU address to auxiliary card RAM, and Q3 falling as described in the section on motherboard clocks the video COLUMN address to auxiliary RAM timing. An access is made to auxiliary card RAM. card RAM at this address during PHASE 0, 3. The 6502 address and R/W' are set up early even if the MPU is not accessing auxiliary card during PHASE 1. R/W' does not affect video RAM. If the MPU is not accessing auxiliary scanner read access to auxiliary card RAM card RAM, EN80' will remain high, forcing because R/W'80 is forced high during PHASE 1 R/W'80 high and disabling the auxiliary card (R/W'80 is gated by EN80' which is gated by bidirectional driver. Since R/W'80 is high, the PHASE 0 inside the MMU). Also, R/W' affects superfluous access to auxiliary card RAM is a thedirection of the auxiliary card bidirectional read access, and the auxiliary card RAM is not data bus driver, but this direction will not mat- modified, even in an MPU write cycle. Since the ter until EN80' falls and enables the bidirec- bidirectional driver is disabled, the data on the tional driver outputs. CASEN' from the MMU auxiliary data bus does not interfere with data rises after the address is set up, but CAS' still bus communication between the MPU and other falls since, in the timing HAL, CASEN' high devices. only disables CAS' during PHASE 0. There- 8. In a write cycle, 6502 write data becomes valid fore, MPU access to devices other than mother- board RAM does not interfere with video on the data bus early during PHASE 0. After the write data becomes valid at the data bus, it is scanner access to motherboard RAM during PHASE 1. propagated through the auxiliary card bidirec- tional driver to the RAM chips. This data must 4. Video data becomes valid on the auxiliary data be valid at the auxiliary data bus before Q3 bus no more than 135 nanoseconds after Q3 falls falls. Auxiliary card RAM timing is less critical assuming 200-nanosecond RAM chips are in- than motherboard RAM timing in this regard stalled. This is 70 nanoseconds later than moth- erboard RAM read data becomes valid, but data falls. because Q3 falls 70 nanoseconds after CAS' .&^ RAM and Memor/ Management 547 6502 PHASE2 "1 Latch video r 6502 data transfer PHASEO \ 'E / ROW \ COLUMN ROW / ROW^ COLUMN COLUMN RAS' m CASEN' EN80' 1 HI EN80' enables and data iransfer AUX fi/W80- RAM m CAS' does not fall because CAS' J 1 CASEN' is high. J 1 ITerminate RAM 03 , data transfer-^ Initiate RAM . Datafloating on stays valid aux data transfer ■TCAC data bus _ MPU yJ': 135 I AUX RAM NOT S MAX /-AuT VtDEO DATA USED DATA (DATA MPU > READ BUS DATA > MOTHERBOARD VIDEO DATA K I DATA > r _/m R/W 1 6502 write data valid before 03 falls R/W'80 > WRITE BUS DATA f MOTHERBOARD I VIDEO DATA AUX K\ \ \ 6502 WRITE DATA \ \ \ \ > auxramIST 6502 WRITE DATA OATA USED VIDEO < OATA > ^ i^^^ '°"''*^ address bus alter MMU propagation E im follows PHASED after um propagation delay. H TCAC Is 135 nsec MAX with 200 nsec RAM chips. Rgure S.15 Timing Diagram: 64K Auxlllory Card RAM Access. ■"s. iiM^ 5-36 Understanding the Apple lie 9. In a read cycle, the read data becomes valid on CONTROL FUNCTION the auxiliary databus no more than 135 nanosec-is SIGNAL Latch ROW address onds after Q3 fallsif 200-nanosecond RAM RAS' falling Save COLUMN address and installed. This data is propagated through the enable RAM chip data transfer auxiliary card bidirectional driver to the data Q31ow RAM chip read/write control bus well before PHASE 2 falls. PH AS E 0 ri si ng Latch video data 10. PHASE 0 falls simultaneously with Q3 rising. Enable aux data to video bus The auxiliary card RAM chips bring their data W' 80 R/ASE 1 low PH LS245 direction control output lines to high impedance no more than 50 R/W LS245 enable nanoseconds after Q3 rises if 200-nanosecond RAM chips are installed. The floating auxiliary These control f u nctions are d ictated by the opera- data bus will store the previous data for a long tion ofmotherboard circuitry. They enable the video period of time so the RAM read data is passed scanner to drive the display map to the auxiliary through the bidirectional driver to the data bus, EN80' latch during PHASE 1, and the MPU to transfer even though the auxiliary data bus is floating. data to and from RAM during PHASE 0. 11. Auxiliary card RAM read data is clocked to the AveryinterestingfeatureofthelK card is that it MPU by PHASE 2 falling. In a write cycle, the responds to EN80' without detecting the $400— 6502 controls the data bus until shortly after PHASE 2 falls. $7F F range. For example, you could set RAMWRT' and store data at $8213, and the IK RAM card 12. PHASE 0 low causes EN80' to rise after MMU would accept the data at the memory location nor- propagation delay. This disables the auxiliary mally addressed at $613. This should cause no harm card bidirectional driver and, in a write cycle, since programs always check for the presence of a causes R/W'80 to start rising. R/W'80 rises 64K card before attempting to store data in auxil- slowly because it is being pulled up by a IK iary card RAM outside of the $400— $7FF range. It resistor. does make it harder to test for a 64K card since either a IK card or a 64K card will allow you to store and read back a value at any RAM address. The THE 1 K AUXILIARY RAM CARD difference is that, when the installed card is a IK A good part of the circuitry of the MMU in the card, you will read back the same value at any Apple lie is devoted to management of 64K of moth- address that is separated from the modified address erboard RAM and 64K of auxiliary card RAM. by a multiple of $400. The following programming Additionally, the 80-column capability is fully im- example tests for a 64K card. plemented intiming and firmware. So fully is the TEST64K STA $C001 SET 80STORE 64KauxilaryRAM/80-column capability supported IDh $C057 SET HIRES that one only has to install a simple card containing IDA $C055 SET PAGE2 a latch, a bidirectional driver, and eight dynamic LDA #$00 RAM chips in the auxiliary slot to achieve the STA $400 CLEAR $400 capability. LDA #$88 STA $2000 CTRL-H TEST VAUJE Apple also developed another card for the auxil- iary slot, one that supports the built-in 80-eolumn CMP $400 WAS $400 MODIFIED? capability but not the 64K auxiliary RAM capabil- BBQ N064K YES: NO 64K CARD ity. This 80-column only card contains a IK static CMP $2000 WAS $2000 MCXJIFIED? RAM and support circuitry. The IK RAM is ad- BNE ND6^ NO: NO 64K CARD dressed bythe MPU at $400— $7FF, and provides CMP $2000 OfflCK AGAIN the display map for the alternate columns of an 80 x 24 text display. Figure 5.16 is a schematic which I BBQ AUXe-MQ YES : 64K CARD POUND SURE* drew from the board since I was unable to locate a BNE N064K TO BE NO: NO 64K CARD schematic in any Apple literature. *If an attempt to read auxiliary card RAM is made and no card is The IK RAM card is very similar to the 64K RAM installed, the MPU will read the last value driven outof mother- board memory by the video scanner. $88 (left arrow) is not likely card in data connection to an LS374 latch and to the to be driven out of motherboard RAM if a normal text display is data bus through an LS245 bidirectional driver. being scanned. Performing a double test for $88 precludes acci- Control of the data transfer functions— identical to dentally reading an $88 driven from the UNUSED 8 during HBL those of the 64K card— are as follows: or VBL.possible of the All auxiliarycontentscard search programs of display memory. should be cognizant RAM and Memory Management 5-39 CUQQCSQDQO 5 Jl .1 Jl ^ H J, i. ,, 1 cvj3 - " "^ ' V " " 5* CD .&L zUJ §- ^v^ ojlr^ -^T Lo to "^ DO m rO'^r^coc^^^oo .£1 T— r-AAA/- D Rop < CvJCs] CD CDS ^fR: <: lA <<<<<<<< c/) o (1> g TT 54 TAX 1089 :A0 88 89 DISMAY WINDCW IS 16 LETTERS WIDE WY 108B:AA 10 DSPLYLE MESSAGE, 108C:BD A7 10 90 #16 X LDA 108F:99 8C 06 91 PRINT MESSAGE 92 STA DEX $68C,Y 1092 :CA 1093 :8A 93 TXA 1094:29 IF 94 AND WRAP AT SIF 1096:88 95 DEY 1097:10 F2 96 BPL #$1F DSPLYLP 1099 :4C 24 10 97 QOBACK JMP VBLLPL GO WAIT P0« NEXT SCAN 98 ************************************************************ 109C:A2 28 99 PENT40 WX PRINT 40 ASTERISKS 109E:A9 AA FD 100 IDA 10A0:20 ED 101 LP40 #40 GOUT 10A3:CA DEX JSR 10A4:D0 FA 102 103 BNE LP40 10A6:60 104 RTS 'Video 105 #■*■ ************************************************************ 10A7:D6 E9 E4 106 MESSAGE ASC 10AA:E5 EF A0 Polling Demonstration ' 10AD:O0 EF E9 EC 10B0:BC EE 10B3:E7 A0 C4 10B6:E5 ED EF 10B9:EE F3 F4 F4 10BC:F2 El 10BF:E9 EF EE AD I0C2:A0 AD % 10C5:AD A0 Igy ************************************************************ *** SOCCESSEUL ASSQCLY: NO ERRORS FIgureS.ia Assembler LitHng: Video Polling Demonttiollon (2 oTS). 4>M ^ chapter 6 ROM in the Apple lie mmm. r^— l^gJl MMm ^ '.II Non-erasable, random access, read only memo- The sophistication of the ROM chips makes their ries have taken many forms in the history of digital connections in the Apple simple and easy to under- computers. From vacuum tubes to diodes to small stand. Nevertheless, the topic of ROM is involved scale integration to large scale integration, there enough to merit its own chapter. For the most part, has always been a need for the general purpose discussion of ROM in this chapter is limited to the computer to have a resident program ready to tell it motherboard CI— DF and EO— FF ROMs, and what to do at turn on. With the coming of large read peripheral slot ROMs containing 6502 machine code only memories on single chips, the scope of pro- and related data. The keyboard ROM and video grams contained in ROM in general purpose com- ROM are covered in Chapters 7 and 8 respectively. puters has expanded greatly. The Apple He design supports 16.128 bytes of ROM HARDWARE motherboard ROM, addressed from $C100 through $FFFF. Additionally, several provisions exist for The Apple lie firmware is programmed into two controlling the Apple via programs in ROM on 2365A type ROMs. The 2365A is a 28-pin, 8192- peripheral cards. These include addressing periph- byte, NMOS ROM with two programmable chip eral ROM using a slot's assigned address area (its select inputs, an OE' input, an CE' input, and 200-, 300-, or 450-nanosecond access time. NMOS stands JCOnX DEVICE SELECT' range and its $CnXX for Negative channel, Metal Oxide Semiconductor i/O SELECT' range), addressing peripheral ROM using the I/O STROBE' ROM addresses ($0800- construction. These technical terms will help you if *CFFP), and inhibiting motherboard memory and stealing addresses $0000— $BFFF and $0100— data look you book.for Look the equivalent chip 8192 under NMOS, in a manufacturer's x 8 ROMs. $PPFF. All told, the Apple He computer has a very A number of manufacturers make 28-pin, 8192- versatile capability for operating under control of byte ROMs which would work in the Apple lie. ^programs stored in ROM. 2365A is the Synertek part number, and it is used 6-2 Understanding the Apple He In Revision A, an auxiliary card can deactivate here because it is used in Apple schematics. It is CE' to disable motherboard ROM by pulling EN- reasonable to assume that 450-nanosecond ROMs are used since this is more than fast enough for FIRM low. I'm not sure what Apple had in mind for Apple He timing. this capability, but they sacrificed it for DOUBLE- RES GRAPHICS in Revision B. The ENFIRM line Masked ROMs used in the Apple He are pro- grammed bythe manufacturer to the specifications was changed to FRCTXT', and the associated NAN D gate is used to force text mode processing at of Apple Computer, Inc. Once thechip is built, only a casualty will cause alteration of the stored data. In the timing HAL by bringing gated GR+2' high addition to specifying thedata to be contained in the when FRCTXT' is low (see Figure 3.9). This enables DaUBLE-RES GRAPHICS processing if SOCOLis ROM, Apple specifies which of the two chip select inputs are active high and which are active low. This set and TEXT is reset. Additionally, the ROM dis- is why the chip selects are said to be programmable. abling mechanization of INHIBIT' was transferred The chip selects of all ROMs on the Apple He to the MM U. In Revision B, all enabling and dis- motherboard— the Cl—DF, EO— FF, video, and abling of the Cl-DF and EO-FF ROMs Is keyboard ROMs— are programmed so the INTEL mechanized via the ROMENl' and R0MEN2' type2764, 2732, or2716EPROMscan be installed in outputs from the MMU to the ROM OE' inputs. their place. Ci— DF and EO— FF ROM connections in the Apple He are shown in Figure 6.1. The ROM chips ROMENr AND ROMEN2' are wired in the way most microcomputer hardware ROMENl' and R0MEN2' are the MMU databus is wired, with repetitious, identical wiring going to management signals which activate the Cl— DF both chips. It takes thirteen lines to address 8192 and EO-FF ROMs respectively. Their mechaniza- bytes, and the thirteen address inputs to the ROM tion in the MMU and descriptions of how ROM fits chips are connected directly to AO— A12 of the into the Apple He memory map are contained in the address bus. The eight tri-state data outputs are memory management sections of Chapter 5, butfea- connected directly to the data bus. These address tures of memory management related to ROM are and data connections are pleasantly simple when reiterated here. contrasted to RAM connections. Motherboard ROM is addressed at $C100- The only remaining connections are power sup- $FFFF, although $D000— $FFFF addressing is ply connections (+5 V and GROUND) and the chip shared with high RAM, and $C100-|CFFF ad- enabling inputs (OE', CE', and the two chip selects). dressing is shared with the peripheral slots, The chip enabling inputs have one thing in common $D0OO— $FFFF is thought of as the primary ROM in that, if any of them is inactive, the tri-state out- range of the Apple He, and it is configured for ROM puts ofthe ROM chip will be held at high impedance. reading and high RAM writing any time RESET' More specifically, for the Cl-DF or EO-FF ROM falls. After a reset, a program can select ROM or of the Apple He to control the data bus, its OE' and high RAM for $D0OO— SFFFF read response by CE' inputs must be low, and its two OS inputs must manipulating the HRAMRD soft switch as de- be high. The CS inputs are both tied to +5 volts in the scribed inChapter 5. When HRAMRD is reset and Apple He so there's not a lot to say about them. OE' INHIBIT' is high, read access to $DO0O-$FFFF and CE' are another story. causes the MMU to bring ROMENl' (IDOOO- CE' is different than the other chip enabling $DFFF) or R0MEN2' ($E0{)0— $FFFF) low dur- inputs because, when it is high (inactive), the ROM ing PHASE 0 (plus MMU propagation delay). chip goes in to a low current standby mode. Power The $C100— $CFFF range of the Apple He is supply loading can thus be reduced by inactivating assigned primarily to the peripheral slots, but pro- CE' whenever ROM is not being accessed. Unfortu- grams can disable slot response and enable ROM nately, enabling the chip via CE' is slow (450 nsec response by manipulating the INTCXROM, SLOT- max) compared to enabling a chip via OE' (150 nsec C3R0M , and INTC8R0M soft switches as described max), so OE' is used as the primary ROM chip in Chapter 5. This occurs regularly since the 80- enabling input in the Apple He. The CE' inputs to column firmware, Apple He diagnostics, and a the ROM chips are used to mechanize the ROM number of monitor subroutines reside in the disabling INHIBIT' and ENFIRM lines on Revi- sion Amotherboards. On Revision B motherboards, $C100-$CFFF range. When INHIBIT' is high and access is made to a $C100— $CFFF address that is CE' is simply tied to ground. configured for motherboard ROM response, the ROM in the Apple Q] In Revision A, ENFIRIVI and INHIBIT' were required to be high before ROM-20 (CP) would drop low. In Revision B, ENFIRM is H0MEN2 o^iiS-'^yintheMMU . and INHIBIT' is a logic input to ROMENr and FRCTXT', Figure 6.1 SchemaHc: ROM in the Apple (le. ^ij;3iiStf,j 6^ Understanding the Apple He DOS PR#n or IN#n or monitor n CONTROL-? or n MMU brings ROMENl' low during PHASE 0 to CONTROL-K commands are executed. An example enable transfer of data from the Cl-DF ROM to the is the bootstrap ROM of the Apple Disk II controller. data bus. The program in this ROM, accessed at $C6XX when Both ROMENl' and R0MEN2' are gated by the controller is installed in Slot 6, begins the boot INHIBIT' from the peripheral slots.* This reveals procedure that causes the DOS image on a diskette some of the power of INHIBIT'. The function of to be transferred to motherboard RAM. The 256- ROM is to place data on the data bus when it is byte program is not nearly big enough to accomplish accessed. When INHIBIT' is low, disabled. ROMENl' and this task, but it is big enough to start the task and R0MEN2' cannot fall and ROM is It is as transfer some code from the diskette to RAM so the if the ROM were not installed. The peripheral card is then free to respond to $D000— $FFFF (and task can be continued. $C100— DFFF if it is configured for motherboard There are actually very few I/O tasks that can be ROM response) in any desired manner. accomplished with a 256-byte driver. For this rea- While ROMENl' and R0MEN2' responses to son, an I/O SELECT' ROM will often be supple- $DOOO"$FFFF are R/W' gated, ROMENl' re- mented bya 2K driver on an I/O STROBE' ROM, sponse to$C100— $CFFF is not. As a result, write The I/O STROBE' signal goes low at the peripheral access to an address in the $C100— $CFFF range slots any time access is made to $C800— CFFF when that is configured for motherboard response causes INTCXROM and INTC8R0M are reset. Under a the MPU to compete with the CI— DF ROM for protocol described in Chapter 7, any peripheral control of the data bus. I'm not sure why Apple card— but only one at a time— can activate response decided not to gate $C100-$CFFF ROMENl' re- to the I/O STROBE'. The I/O STROBE' could be sponse with R/W', but I speculate that it was to util ized to enable any sort of peripheral card device, achieve a misguided form of compatibility with the but it is almost always used to enable a 2K ROM I/O SELECT' and I/O STROBE' signals, I/O SE- containing some sort of I/O driver. LECT' and I/O STROBE' respond to read and write The third type of peripheral slot ROM is utilized access to$ClOO-$CFFF. Why notmake ROMENl' in conjunction with the INHIBIT' line which is a the same? I mean, you never know when one of those peripheral slot output, as opposed to the I/O SE- programmers is going to want to write to mother- LECT' and I/O STROBE' inputs. Whereas the I/O board ROM. SELECT' and I/O STROBE' outputs are ROM en- abling signals that allow the MPU to access periph- PERIPHERAL SLOT ROM eral card ROM, the INHIBIT' output is a memory disabling signal that allows peripheral cards to In addition to the 01— DF and EO— FF ROMs, a selectively disable motherboard and auxiliary card typical Apple lie will have several peripheral card memory in favor of peripheral card response to ROMs that contain programs which can be executed MPU addressing. by the 6502. Generally, these will be I/O SELECT' An INHIBIT' based peripheral does not have ROMs addressed at $CnXX, I/O STROBE' ROMs to substitute ROM for motherboard memory, but addressed at $C800-$CFFF, or INHIBIT' ROMs it certainly can. An example of a peripheral that addressed anywhere in the $0000— $BFFF and does so is Apple's 12K firmware card which steals $C100-$FFFF ranges. I/O SELECT' and I/O $DOO0— $FFFF from motherboard memory and STROBE' ROMs respond to the I/O SELECT' or substitutes peripheral card ROM or EPROM. I/O STROBE' peripheral slot inputs, and normally Through the 12K firmware card, an Apple He user contain programs which implement the I/O func- can have the convenience of both Applesoft and tions ofa peripheral card. Peripheral card INHIB- Integer BASIC in ROM. IT' ROMs utilize the INHIBIT' output of the peripheral slots to substitute peripheral card resi- ROM TIMING dent programs and data for motherboard resident programs and data. ROM read timing is very simple and is the same An I/O SELECT' ROM contains a 256-byte pro- for read access to the Cl-DF, EO— FF, or keyboard gram which initializes I/O at a slot when BASIC/ ROMs. Among the points to consider are the timing •As described in Chapter 5, CASEN' and EN80' are also gated characteristics of the ROM chips, disabling of by INHIBIT' so MPU communication with RAM, as well as motherboard and auxiliary card RAM via CASEN ROM, is disabled when INHIBIT' is low. and EN80', and enabling of the addressed ROM via ^iMW P^iSv^.":''- ROM in the Apple He 6-5 ROMENl', R0MEN2', or KBD'. Assuming Apple ROM read timing in the Apple He is illustrated in uses 450-nanosecond ROM, important timing char- Figure 6.2. The main order of events is: acteristics are as follows: 1. During PHASE 1, the video scanner performs 1. The output data will become valid a maximum its normal access to RAM. of 450 nanoseconds after the address input 2. At approximately 100 nanoseconds after 6502 becomes valid. PHASE 2 falls, the MPU address becomes 2. The output data will become valid a maximum valid. ROM data will be valid no more than 450 of 150 nanoseconds after the OE' input falls.* 3. The data output will go to high impedance a •Values given are for Synertek SY2365 ROM. Some ROM manu- maximum of 150 nanoseconds after the OE' ond ROM. facturers have shorter OE' access specifications for 450 nanosec- input rises.* "T 6502 PHASE2 r PHASED 1 CASEN' 52nsec [O R0MEN2' DATA MPU /iviotherboard\ y BUS DATA \ VIDEO DATA / \ ROM DATA VALID 450 ■ nsec - max 6502 address typically becoimes ROM data becomes valid no more than valid 100 nanoseconcis after PHASE2 falls. 150 nsec falls, and after ROMENT no more or ROMENZ' than 450 nsec after the address becomes valid. Q] In the Apple He. the 450 nanosecond maximum delay from address valid to data valid is usually NOTES: met before ROMENl' or R0MEf^2' has been low for 150 nanoseconds. Q] Experimental value measured in author's Apple lie. (E Maximum OE' access time (TAOE) varies with ROM manufacturers. Maximum TAOE of General Instruments R09864AB is 75 nsec, but maximum TAOE of a Synertek SY2365A is 150 nsec. Figure 62 Timing Diagram: Read Access to the EO— FF ROM. rm'^n 6-6 Understanding the Apple He firmware and to provide some insight into the nt iUh pointly M OE' longe. ROnnother- importance of the programs contained there. The input inn.iose nan nas con t has er beenaftlow d, oee suffs icie thi ii. u e wm approach is historical, beginning with the Apple II 3 If accesis in the previous cyci and progressing to the recently released firmware CAS EN' rise s when the ROM board RAM, lie. MM U propaga ion AppleInteger to the was First,s there upgrade address becomes valid plus BASIC, the monitor ef:; TSiswiU disable dur MPU co-mu-ation ROM and some 6502 utilities. These programs were ^AM ing PHASE 0. with mother boa rd ROM ENl ROMt-NZ , written primarily by Steve Wozniak, the designer of A PHASE Crises, caus ing p-v-s the original Apple II computer. This was in the bad '■ r^KBD' to fall and EN80' to rise Of RAM) alter old days before the proliferation of inexpensive disk card cvcle access was to auxiliary drives, and before Microsoft Inc. started supplying delay. CAS' and Q3 also rise MMU propagation rises, terminating the video all the'computereters. companies with more sophisticated when PHASE 0 Integer BASIC takes up about data bus hen BASIC interpr Scanner access to RAM. The nt limita- board video data until the 5K of memory and has some very importa ?loats, storing mother tions- no floating point arithmetic, no HIRES ROM data becomes valid. r the KOM en ffraphies commands, and no issubscri pted string vari- 5 150 nanoseconds maximum afte becomes valid. ables toname three. This not said to belittle th^ ablingsignalfalKtheRO Mda ta vahd early nts of Mr. Woz- assuming the address bus became considerable design accomplishme A and ROM chip, niak. It's just that within a few years, Integer enough. With a typical 6502 that the the address beco mes valid early e"™ gh BASIC became less than state-of-the-art. C OE' to data valid delay of the ROM chip will The 6502 utilities included with Integer BAi»i nes, the determine when data beco mes vali d. In any were some floating point arithmetic routi case, ROM data beco mes vali d well befo re hbi)Z "SWEET 16" double word length command inter- preter, and most importantly, thestica Mini-Assembler. SWE ET 16 is a small but sophi ted computer PHAS E 2 fall- 6 PHASE 0 falls','followed by 6502 ' h lets the prog ramm er manipulate owed R0MENl by cycle ',R0ME N2',orKBD language whic ing foll g (if next acces s is not to the sanie word lengt hs. It utili zes RAM ad- risin next cycle data in 16-bit regis ters of 16 bits ROM chip), and EN80' falli ng (if dresses $0through $1F as 16 RAM) . MMU prop a- l machi ne langu age comm ands access is to auxiliary card each, and has norma gation delay is longer than 6502 PHASE 0 to :uchasADD ,SU BTR ACT ,CO MPA RE, BRA NCH lie PHASE 2 propagation delay m my Apple programs in SWEE'T lb wUi ROM will control etc. Writing some less space than the equivalent 6502 and perh aps in all Appl e He's. ds make them take the databus for a maximum of 150nanosecon wil run faster. after its OE' input rises. program, but the 6502 progisram the utility on which , t, . n/, The Mini -Ass embl er KAM, 7 If next cycle access is to motherboard uncounted prog numbers of Applmbly e owners have ir^ fall when the next addre ss be- lear ned to ram 6502 asse ^^rim^e^-j^l^^ ' CASE N' will comes valid plus MMU propagation delay. forlleOnly. . ^. Man rmce v^ „„„„„* is fully described in the Apple II Refe IN THE APPLE routinesare not FIRMWARE SWEET 16 and the floating pomt d Appl e Uter aturejn the ately deter- described in any publishe The hard features of the Apple ultimHowev er, the old red Appl e II refe renc e manu al there are sou ce/ mine its capabilities and limit ation s. ting pomt rou object listings of SWEET 16, the floa prog ram con- computer is only as powerfulnt.as the Possibly the most tines, and the Mini -Ass embl er. SWE ET 16 is ^^y trol ing itat any given mome described in the November. l^J^ edition dB^, important programs ever written for the Apple give are WEE.T 16: the 6502 Dream Machine ("Siak) the ones stored in the motherboard ROM. These maga by zine Stev e Wozn life to the machine and are used so often that we programs and that opera- The System Monitor forget that they are just tional features created by any program can be em monitor changed. In microcomputer terminology, a syst aini ng the most basic utilities oi The contents of Apple II and Apple He firmware is a program cont ation of BASI C in Kuni, have been the subject of many writings which this the system. Before the innov user inter lace » a moni tor in ROM was the prim ary book cannot hope to match in a limited space. The routi nes of a syswm goal here is just to give an overview of the Apple the microcomputer. Some basic t routi nes, video output monitor are keyboard inpu .^ ,,:$,?:&■ ROM in the Apple He 6-7 routines, memory display and modification rou- exactly what Apple did when they decided to change tines, and storage media input/output routines. a few operational features of their computer. The Apple was one of the microcomputers which led the transition from a monitor in ROM to BASIC The Apple II Plus in ROM as the primary human to machine interface The Apple II evolved rapidly in the late 1970s into for home computers. However, the Apple does have a more sophisticated machine than was originally an extensive monitor in ROM, and the older Apples introduced. The dynamic nature of the hardware came up in the system monitor, not in BASIC. and software support provided to the Apple II by The original Apple II system monitor contained Apple mateinorder, 1978 and 1979 is remarkable. In approxi- such important Apple utilities as entry to BASIC, keyboard input, video text and LORES graphics output, cassette I/O, assignment of different periph- 1. DOS, Applesoft BASIC became available on cassette, eral slots as primary input or output, memory dis- 2. The Disk II was introduced with its powerful play and modification, a 6502 disassembler, mach ine language single step, trace, or normal subroutine 3. Applesoft became available on diskette, 4. Applesoft became available on a firmware card, execution, handlers for RESET', NMI', IRQ', and 5. The Apple II Plus was released with Applesoft BREAK, and some 16-bit multiply and divide rou- and Autostart monitor in ROM, tines. Control of the monitor is via a highly usable command interpreter, the use of which is well de- 6. The Language System was released with 16K scribed inthe reference manual. RAM card, Pascal language, and 16-sector disk capability, and This, then, was the Apple: a cassette based system 7. DOS 3.3 was released with its 1 6-sector capabil - with a poor man's BASIC and a rich man's monitor ity (August 1980). in ROM and two empty 2K ROM sockets for user firmware. Oh yes, one more important thing— Apple A popular Apple configuration became both Integer published a source/object 1 isting of the system moni- BASIC and Applesoft in ROM with automatic selec- tor. This was a rislty move which paid off immea- tion between the two by the DOS when a program surably. Bypublishing their listing, Apple opened was RUN. One BASIC resided in motherboard the way for investigators to learn thoroughly the ROM, and the other resided in ROM on a Slot 0 firm- nuts and bolts operation of the Apple. They thus ware card. As this configuration demonstrates, aided competitors in developing numerous software bank switching of firmware operating systems is a and hardware applications for the Apple II. With very powerful concept. this combination of extensive available applications The availability of Applesoft BASIC greatly and freedom of information, Apple pulled off the improved the versatility of the Apple by making the delicate trick of appealing not only to the masses manipulation of the HIRES screen, large disk text who don't care how it works but also to more serious files, and floating point numbers practical. Unfortu- users who develop even more applications. nate Applesoft weaknesses were incompatibility in The system monitor dictates many of the opera- command and memory usage with Integer BASIC, tional characteristics of the Apple: what happens no AUTO numbering, no DSP(DiSPlay) command, »hen the computer is turned on or RESET is and the absence of the 6502 Mini-Assembler. Also, pressed, the format of the screen text, the nature of the SWEET 16 interpreter and old floating point iursor moves, and the assignment of primary input routines which are associated with Integer BASIC ind output devices. The monitor zero page assign- are not available with Applesoft. nents must be taken into account by software The new Autostart monitor reflected the chang- lesigners. Page 2 of RAM is thought of as the Apple ing nature of the personal computer owner. It :eyboard input buffer because that is the way the caused the Apple to come up in BASIC instead of the nonitor uses Page 2. Cards capable of being pri- system monitor, gave the Apple the capability to mary input or output dev ices must have programs at boot a disk at power up, and greatly improved the tieir I/O SELECT' addresses, because the firm- ESCape mode cursor moves. In the process, the ware assigns a slot as^ primary input or output by SINGLE STEP and TRACE investigative utilities ^wiping to the slot's first I/O SELECT' address for machine language programs and the 16-bit mul- ftlOO for Slot I, $C200 for Slot 2, etc.). These fea- tiply and divide routines were removed. Program- wea are not inviolate in the Apple. They can be mers' utilities were thus sacrificed for improved *"^ ^y loading a new operating system into operational features. The small businessmen gained AM or by replacing a single ROM chip, which is a system that automatically loads and starts at "»i,.i.i 6-8 Understanding the Apple He 80-column firmware accomplishes the task of main- power up, and the computer hacks lost the conve- taining the alternating column auxiliary card and nience ofSTEP and TRACE in ROM. motherboard RAM text display map. It also per- The Impact of the RAM Card forms some Pascal housekeeping and interprets special control and escape characters that are used An eventual development in the evolution of the to manipulate the text display. Additionally, the Apple ir was the popularity of the 16K RAM card. XFER (transfer control between motherboard and With a disk based system, as the Apple had become, auxiliary card RAM) and AUXMOVE (transfer it was no longer as necessary to have extensive oper- data between motherboard and auxiliary card ating systems in ROM as it was with a cassette based RAM) utilities reside in the $C3XX range and are system. The entire Integer BASIC program and associated utilities could be loaded into the $E000— considered to be part of the 80-column firmware. $F7FF area of the 16K card in a tolerably short To make room for the firmware necessities of the period of time, giving the user the equivalent of the Apple lie, Apple switched from 12Kof ROM in the firmware card but more versatility. The system Apple II to 16K of ROM in the Apple lie. They could monitor became alterable by the user, and the have accomplished the same thing by bank switch- number of operating systems that might possibly ing the $D000— DFFF range with ROM as is done reside in high memory became unlimited. The dis- with high RAM, but they chose, instead, to switch advantages ofthe 16K RAM card were the possibil- the $C100— $CFFF between I/O and ROM. This ig ity of overwriting high memory, occasional extra consistent with the concept of an emulated Slot 3 waiting for loading the program into the 16K RAM 80-column card. Slot 3 firmware is accessed at card from disk, the impossibility of protecting 6502 $C3XX and $C800— $CFFF. and so is the Apple He vectors from program encrypting artists, and the 80-column firmware. lost capability of other peripheral cards to respond Other than the presence of 80-column firmware, to $F800— $FFFF addressing. For most users, the the monitor in the Apple He is nearly identical to the advantages of the 16K RAM card outweighed the Apple II Autostart monitor. There are some modifi- disadvantages. cations, such as a new KEYIN routine, interpre- tation of ESCAPE arrow cursor moves, and Ttie Apple lie interpretation of open and close Apple keys at reset In early 1983, Apple released the Apple He com- time. The modifications increase the size of the mon- puter, an improved Apple II with increased firm- itor and necessitate the location of some monitor ware requirements. The Apple lie is a 128K, upper/ routines in the $0100— $C2FF addressing range. lower ease, 80-column computer designed to emu- These routines are called by executing GOTOCX at late a48K Apple II with 16K RAM card in Slot 0 and $FBB4 with the index of the desired routine in the Y-register. 80-eolumn display card in Slot 3. The 16K RAM card emulation is strictly a hardware mechaniza- Another firmware addition made in the Apple He tion with 64K of motherboard RAM, MMU soft is the built-in diagnostics at $C400— $C7FF. This is switches controlled by $C08X access, and data the only portion of the $C100— $CFFF firmware for bus management via the ROMENl', R0MEN2', which Apple did not publish a listing. The diagnos- CASEN', and EN80' MMU outputs. Two very im- tics include checks of the ability to control and read portant operational improvements over the 16K lOU and MMU soft switches, checksum computa- RAM card are that high RAM is disabled when tions for the CI— DF and EO— FF ROMs, and a INHIBIT' is low, and that high RAM is disabled for complete check of motherboard (but not auxiliary reading and enabled for writing any time RESET' card) RAM, falls. The bottom 256 bytes of the Cl—DF ROM cannot The 80-column card emulation is also a hardware be read by the MPU since ROM is not addressed at mechanization and is implemented in the timing $COXX. I put the ROM in my PROM burner to see generator, auxiliary RAM card, video generator, what Apple puts in the this unaccessed portion. The and MMU. Additionally, extensive new firmware is answer? All zeroes. utilized to accomplish 80-column text output. The 80-column firmware of the Apple lie core- me Apple lie Firmware Upgrade sides, in ROM, with the old 40-eolumn firmware of When Apple developed the Apple He, they had to the Apple II. The 40-column firmware is enabled at struggle with the sometimes conflicting goals of power up or system reset, and the 80-column firm- building the best computer possible and retaining ware must be selected via IN#3 or PR#3. The maximum compatibility with the Apple II. Some of ROM in the Apple He 6-9 the resulting compromises were less than perfect. the INVERSE upper case patterns at addresses My primary dislikes are the treatment of the 80- $200-$2FF (see Figure 8.8). The video ROM with column capability as a Slot 3 peripheral, the fail- ure to upgrade Applesoft commands to support "mouse text" is installed in all Apple lie's, and it is included in the firmware upgrade to the Apple lie. DOUBLE-RES GRAPHICS, and the failure to up- There is still an INVE RSE upper case set at $000— grade BASIC and monitor command interpretation $OFF of the new video ROM. so this capability is not subroutines so that lower case keyboard input can be lost. However, INVERSE video output routines interpreted as commands. which output INVERSE upper case text characters Whiledevelopingthe Apple lie, Appleeliminated by storing $40— $5F in the display map and setting this last imperfection and made some other changes ALTCHRSET will display mouse icons instead of to the firmware. These changes support Apple lie the ROM.desired text characters with the mousy video features including built-in mouse capability, gen- eral I/O structure, and 65C02 MPU, The firmware In addition to the "mouse text" in the video ROM, improvements in the Apple He program have there are improvements to the system monitor, the spawned a firmware upgrade to the Apple He. This 80-column firmware, and Applesoft in the firm ware upgrade is expected to be released at approx imately upgrade. These include a new IRQ'/BREAK hand- the same time as this book. Based on a preliminary ler, a6502 miniassembler, an ASCII (in addition version that Apple supplied, some features of the to hexadecimal) monitor input mode, a monitor firmware upgrade are briefly described here.* SEARCH command, faster and smoother 80-column The goals of the firmware upgrade are to maxi- firmware text scrolling, and monitor, Applesoft, mize Apple Ile/IIc compatibility, to integrate dis- Pascal, and ProDOS interpretation of lowercase played icons into the Apple lie display, and to make commands. To make room for these improvements, genera] improvements to Apple lie firmware. In- various routines in the $CXXX and $F775— $FFFF cluded inthe package are new CI— DF and EO~FF ranges are streamlined, relocated, or eliminated. ROMs, a new video ROM. and a 65C02 MPU. Most notably, the firmware diagnostics are reduced Icons are pictures that represent things, and in length by nearly two memory pages. Apple today is a champion of the concept of repre- The new firmware upgrade looks like a winner. senting computer actions with icons on the screen Substantial operational improvements are made to and selecting the action by "pointing" at it with a the Apple lie, and the user gives up little in return. mouse. In line with this company policy, Apple has My suspicion is that the new firmware and 65C02 developed a video ROM with icon patterns replacing MPU will quickly make their way into the majority of Apple He's and that the characteristics of the *Ai30see the NMI' and IRQ' and 65C02 MICROPROCESSOR enhanced firmware will come to represent the oper- sections ot Chapter 4. ational characteristics of the Apple He. 6-10 Understanding the Apple lie HARDWARE/SOFTWARE APPLICATION MODIFYING THE SYSTEM MONITOR $C401 by holding down close Apple and pressing The system mon itor deter in ines and m any of the oper- CONTROL-RESET. Programs beginning at other ational features of the Apple He, modifying the one way of enhanc ing the Apple locations in the $C400— $C7FF range can be exe- system monito r is cu ted by setting INTCX ROM and call ing them via a lie The monitor resides in the $F800 to $FFFF JMP pr JSR instruction. Replacing the diagnostics space of the EO-FF ROM, and the $C100-$C2FF with your firmware applications doesn't mean that space of the Cl-DF ROM.* It is easily modified in the Apple He self-diagnostic capability is perma- high RAM by the user and by commercial give pro- nently lost. It only means you would have to install grams, so modifying the monitor in RAM will the standard Apple CI— DF ROM to run the firm- you access to your personal utilities but won't neees- ware diagnostics, sariiy help you investigate programs written by others. If you want an unalterable modification, you The idea in making a minor modification to the must make it in EPROM and have your Apple con- system monitor is to create an EPROM with con- figured sothat you can override software control to tents identical to the monitor except for small areas enable your EPROM. which contain your data. One idea for modification The system monitor is a fine program with is to increase the command repertoire of the moni- tor. STEP and TRACE routines were deleted when some good utilities that you probably don't want the Autostart monitor was developed. This opened to delete. However, addresses $FCC9-$FD0B, $FECD—$FEF5, and $FEFD—$FF2C are cassette space for two commands in the command tables read/write routines that are rarely used in a disk (CHRTBL and SUETBL) of the monitor. If you based Apple He. Modify the cassette routines to run delete the cassette routines, that will also open up at a RAM address and save them on diskette. This two more command spaces since the READ and generates 156 bytes for your personal firmware WRITE commands will no longer function. which can be increased to 164 by moving the control- What sort of commands can be installed? Here are Y JMP statement to $FEC2. This is accomplished some possibilities: by storing $4C, $F8, and $03 at $FEC2— $FEC4 and by storing $C1 at $FFE4. 1. Breakpoint insert and breakpoint remove com- Other areas of interest to monitor modifiers are in mands which facilitate the use of the 6502 the 80-column firmware and the firmware diagnos- BREAK instruction as a debugging breakpoint. tic routines. There are 13 consecutive unused bytes 2. Hex to decimal and decimal to hex commands. at $C3F3— C3FF, four consecutive unused bytes at 3. A Hex/ASCII memory dump command. $C9A6— $C9A9, and four consecutive unused bytes 4. "Click on" and "click off control of a keypress click simulator. at $C7FC— $C7FF. These locations are convenient areas for making minor patches to the GOTOCX cal, or CP/M.that enter Applesoft, Integer, Pas- 5. Commands subroutines. If you need more room for a firmware application 6. Com mands that con nect and disconnect DOS 3.3 or ProDOS. than provided by the above suggestions, you can make room for 1024 continuous bytes of code by 7. A command to transfer the DOS 3.3 or ProDOS eliminating the firmware diagnostics. What's more, from EPROM on a firmware card to RAM. you can execute any program that begins at 8. A dump screen to printer command that links to your printer driver on a peripheral card I/O STROBE' ROM. ♦Address references in this application note are valid in the The possibilities are endless. original Apple He firmware, but some are not valid in Apple's reeen tly released Apple I le firmware upgrade. Note particularly that, in a preliminary version of the enhanced firmware, the You can modify the system monitor without diagnostics reside at $C600— $C7FF, some monitor and Apple- changing the command table. One idea is to change soft cassette read/write routines reside at $C500— $C5FF, no the ESCAPE handler to recognize special func- ROM cheek is performed in the diagnostics, and the STEP and tions. For example, you can assign ESCAPE-G to TRACE spots in the monitor command tables are taken by Graphics, ESCAPE-T to Text, and so on to give SEARCH and M INI-ASSE MBLE R commands. Check you r list- ing before you attempt to apply the techniques of this application yourself control of the screen modes from BASIC, note to an enhanced firmware Apple lie. the monitor, and many other keyboard polling programs. ROM in the Apple lie 6-11 FA62: C0 BIT 2C 10 RESET KEYSTROBE; READ AKD FA65: BPL $C010 10 03 FA67: 4C 59 FF $FA6A JMP JUMP TO MONITOR IF AKD FA6A: D8 84 CLD $FF59 20 JSR DO He RESET STUFF FA6B: FE SETNORM FA6E: 20 93 JSR $FE84 2F FB INIT FA71; 20 FE JSR ,$FB2F SETVID FA74: JSR $FE93 SETKBD 89 FA77: A0 05 LDY $FE89 FA79: 20 B4 FB JSR GOTOCX: INDEX 5 FA7C: AD FF CF LDA #5 $FBB4 FA7F: C3 $CFFF I/O STROBE' ROM OFF DFB NOP CHECKSUM COMPENSATION FA80: EA FA81: NOP EA ?G3 Here is an example of a change to the system not produce the correct compensation for checksum monitor that does not delete any routines or capabil- procedures based on exclusive-ORing or anything other than simple MOD $100 addition. ities but would still benefit the Apple Ile'user. It modifies the RESET routine to beg'in by checking If your only intention is to make the firmware the AKD flag to see if a matrix key is being held diagnostic checksum procedure pass, you can di- down, If a key is not being held down, then the rectly modify the procedure check byte location normal Autostart reset is performed. If a key is rather than using a separate compensation byte. being heLd down, then the old monitor reset is per- The C 1— DF ROM check byte location is $C400. and formed. With this modification in firmware, the the EO— FF ROM check byte location is $F7FF. user may cause a reset entry to the monitor anytime Programs that require checksum or other verifi- he wishes by holding a convenient key while press- cation ofmotherboard ROM before they will work ing then releasing CONTROL-RESET, but the correctly are one of the more nettlesome develop- normal reset is still the Autostart reset. ments inApple software publishing. I am sorry to To create an EPROM with this modification, use say that Apple Computer, Inc. has taken up this -he monitor MOVE command to transfer the EO— annoying practice, and that ProDOS will not boot FF ROM contents to the area of RAM used as the with many ROM modifications. The best way around lutput buffer of your PROM burner. Then, begin- the checksummers is to place your modified moni- ling at the address corresponding to $FA62, store tor, coresidentwith an unmodified Apple He moni- he code above. These addresses are identical in both tor, in a 27128 EPROM instead of a 2764. Install ■he original Apple He monitor and in the 1985 your double monitor EPROM through a socket/ irmware upgrade. adaptor which has pin 26 iAU) bent out and con- This modified reset handler takes advantage of nected to+5 volts or ground via a manual switch. »me redundancies in the Apple. He monitor reset This will enable you to easily switch to the standard >andler to make room for an AKD check and a monitor any time you need its features. With this ■hecksum compensation byte. The redundancies are setup, you can make some borderline changes which hat decimal mode is cleared twice (at $FA62 and you wouldn't want to do if you were stuck with the PA81) and that ANO and ANl are reset (LDA modified monitor all the time. C058; LDA $C05A) even though this is done auto- As a final word of advice, you should tag your latically in the lOU when RESET' falls. Addition- modified monitor so you can recognize when it is lly, space is saved since read access to $C010 both active. It can be tagged audibly by changing loca- sads the AKD flag and resets the KEYSTROBE tion $FBE5 from $0C to $16. This noticeably lowers >ft witch. the pitch of the Apple's BELL so that you can verify The checksum compensation value, $C3, is equal your EPROM is active by pressing CONTROL-G or 'the MOD $100 sum of the deleted data minus the RESET. You can tag your EPROM visually at 3w data. Therefore, the MOD $100 sum of the power up by changing the contents of $FB09— itire EO-FP ROM is the same as it was before $FB10 to an ASCII message of your choice. For Mifieation, This will makethefirmwarediagnos- example, instead of "Apple 11" you might have your ..Checksum procedure pass, and it will also enable screen display "KAZOO 11" or some other such per- me software that performs a checksum on the tinent title. Remember to adjust your checksum onitor to run with your modified monitor. It compensation byte for any data that you change. will 6-12 Understanding the Apple lie HARDWARE APPLICATION MODIFYING A 12K FIRMWARE CARD INTO A 24K DOS HOSS FUNCTION Can persons who own a 12K firmware card make ADDRESS use of it in the Apple He? Darn right. The firmware HOSS ON, BANK 0 card will operate in any Apple lie slot. If the card $C080,X HOSS OFF, BANK 0 contains Integer BASIC and you make a mmor $C081,X HOSS ON, BANK 1 will have the ultra conve- $C082,X HOSS OFF, BANK 1 change to DOS 3.3, your BASIC that was realized nient access to Intege $C083,X with a Slot 0 firmware card in the Apple 11. The When the modified firmware card is installed change to DOS consists of changing the $C08X lan- (with the enable switch in the up position), it inter guage finding commands at $A5B7 and $A5BF to cepts and processes the Apple He system reset. You $COnX commands where n equals the firmware may handle resets any way you like, but there must card slot number plus $8. be areset vector at$FFFC/$FFFD of bankOpoint- Before you rush off to modify DOS 3.3 and install ing to some sort of reset handler. The concept that is your Integer firmware card in your Apple lie, eon- presented here is that of a DOS/Integer "boss" that template a firmware card that gives you instan- transfers DOS 3.3 and Integer BASIC to their nor- taneous access to DOS 3.3 in addition to Integer mal locations in RAM at power up and other times BASIC. Wouldn't it be nice to have a firmware card selected by the operator. that contained the DOS and would alleviate the Figure 6.5 is a map of the DOS HOSS. Bank 0 is necessity ofwaiting for a disk boot anytime you turn filled with Integer BASIC, an Apple He monitor on the Apple He. Well, if you own a 12K firmware with special reset vector, and the main body of the card, a soldering iron, some 2732 EPROM, and a reset handler. DOS 3.3 is in bank 1, as well as a little time, you own that DOS/Integer firmware MOVEDOS routine that transfers the DOS to RAM. card. I call this super firmware card the DOS The main reset handler processes all resets, and, if HOSS, and the purpose of this application note is to show you how to convert a 12K firmware card into a transfer of the DOS to RAM is required, switches 24K DOS HOSS. control to the bank 1 MOVEDOS routine, and Figure 6.3 is a schematic diagram of the 12K receives control after the DOS transfer is complete. firmware card taken from Understanding the Apple The DOS HOSS reset handler and MOVEDOS II. Please refer to that book for a complete descrip- routines are shown in Figures 6,6 and 6.7. With this tion ofthe firmware card. Briefly, it is an INHIBIT' reset handler, there are three types of resets. A spe- based, 12K firmware card with six 24-pin sockets cial reset occurs when the operator holds down a meant to accept 2K Apple II ROMs or 2716 matrix key while CONTROL-RESET is pressed (as EPROMs. It is enabled when RESET' falls with the signaled by the AKD flag). A power-up reset enable switch on, or when a program causes even occurs when a matrix key is not being held and the access to $COnX where n is slot number plus $8. It is contents of power-up location ($3F 4) are not equal to disabled when RESET' falls with the enable switch the exclusive-OR of $A5 and the contents of $3F3. If off or when a program causes odd access to $COnX. the power-up byte is okay and no matrix key is being The DOS HOSS hardware conversion consists of held, the rd normal reset handler at $FA62 of the wiring up the unused half of the 74LS74 dual D motherboa is executed. flip-flop as a programmable bank switching flip- The power-up reset consists of transferring DOS flop as shown in Figure 6,4,* The output of this 3.3 and Integer to their normal RAM locations and flip-flop is tied to the All (pin 21) input of the EPROM sockets. This divides the card into two 12K initializing the DOS. A disk boot is not performed, so your disk drive will not automatically start up at banks, one of which is enabled every time RESET' power up when the DOS HOSS is installed. It drops (assuming the enable switch is on). When the doesn't need to because the DOS is instantly avail- firmware card is modified as shown in Figure 6.4, able in RAM at power pl up, just e. as if it were built .mto, the the Ap program control is via access to the following ad- dresses with slot number times $10 in the X-register: The special resets are some actions which it is •Please read the NOTE OF CAUTION at the beginning of the occasionally convenient for an operator to force. The book before making any modification to your hardware. reader is encouraged to expand or improve these special resets since there is a lot of room for more V'^ ROM in the Apple He 6-13 ^/ - > □0 ^ OJ CO ®®®®@®@® CM »-i t*> tfi o> fO r^/,\ A k =3 5 s A 4 ^ V ^ w— r-. oi kn n ^£3 ^oocDcac^ao ^~ S^ o 0) 3 O) 6-14 Understanding the Apple He +5V FROM n B2-14 BANK1 SELECT A1 FROM — ^ TO ROM 00. PIN 21 ROM D8, PIN 7 Disconnect one lead of R2 DEVICE SELECT' 3 R2 FR0MB2-11 2716 R1 / Solder RESET' (31> R1 jumper Figure 64 Converting a 12K Firmware Card into a 24K DOS HOSS. code in the DOS HOSS. Tlie special resets supported should be $0A, $D8. There are a couple of uncompli- by tlie Figure 6.6 listing are as follows: cated bank switching protocols used. First, $D000— RESET ACTION $D809 in bank 0 and bank 1 is reserved for OPEN APPLE transferring control between bank 0 and bank 1 Forced disk boot when the bank 1 MOVEDOS routine is called. CLOSE APPLE Diagnostic execution C Second , a $60 (RTS) located at $DB02 of Applesoft is Catalog disk I Integer transfer only used to accept program flow on the motherboard when the DOS HOSS is turned off. A motherboard M Enter monitor B routine is selected for execution by placing its (Boot only) transfer DOS only address minus one on the stack before exiting to the H Execute disk program named motherboard RTS. HELLO A (or other) Program control of the DOS HOSS in Figures 6.6 Forced power-up reset and 6.7 is via fixed slot commands. You must select The reset handler is a simple keyboard command the slot in which the DOS HOSS resides at lines 38 interpreter and executer. It begins at $D80A, so the and 39 of Figure 6.6 and line 19 of Figure 6.7 before contents of ?FFFC/$FFFD in the bank 0 F8 ROM assembly. DB EO EB FO F8 BANKO RESET INT INT (INTEGER) HANDLER EO ' E8 FO INT MONITOR DOS DOS DOS BANK1 9D-9F. AG DOS DOS i (DOS) MOVEDOS. A8 BO B8 HYioryMap Figure 65 n leDOSHOS SM« m ROM in the Apple He 6-15 O aSmSalal?: ss: as Bo iz C3 3 E fN i-P D pj n IN I- O .-(^K£easrasmi3EE0'4C-^a>ffit!9r a ^ -Qh ^ Am s B n < sa»Bsiantaais< 6-16 Understanding the Apple lie :e . :g §^ I g ii it : lei see :l Is cl g £1 isiE^ : ||g Ig g : "- "^^ ?? : I u« i g: g g s:33 II Ss s i" I ™: I ™ _, : ^11 41 « * * S~t B4 r" ^^■■*u^■\Df~■»oiCSMf^1rl*■^fl*fi^~l^oo^S'-^o<'^•*lf>\or^ooo^ffl'-^^^l■l^v^A^ir^OTtfllS'-^M'<'■*^^'*l^coo^s^ r^l^l^^^l^^^r-co^J^n^noomaoooQOQDo^ratoS--tl^<-HIHr-4l-H^^^4lNOl{N^^lr^l^^l^slOllN^4lN^<^J^4^!^ s a 8S e SE; S5 s as ■< bj CD < i-ii-iearwrf f^mMtJiSfNs fs f^< ^doo cos \o -h b:^ C in lu 0OOOM^f-1S^''*kE'^'^™(NQ--*&i CumiD.Qi\oSCO m oafc in-l5s -urn Cu [L| Uq- o^cntTicnO all^^V^ ClQ(T^u-iLna^iriL/>a^Lnu-iiscDCN[api4aQ(sQa£aol <']|>a;coCOO.CUiVC S(N»SQ#tOiBsm i4:>4;40D(JCl0Oa'Hi— 1>— ii— (EN JEM{M(MCNr4rnimr^ ^nnriiv^r^r^ cc aooOCDcOiH ODfpOlttOfiJiB(JifXf0t(fiiOiy^Q^9^(Tif7^'TO^iTiiTttTtlJy^QiiTy C^ ff^ i!f> ^ 0\ O^ Qi* O^ Ct ijy njn MTS saarrs- -E CMJ! .n Mxr X' psxr SKX' .1? [3!ff WBH « £3 A^^ OaOTW 1^^ CTXX' atn UT4 CiBy t3. -*l 3* 39' »•! got 61361 am .« CTXX suer? caw com CiZ ri > -II .15 cent ^^^UZSL. SLOTI SLOTS ^-' !>--==.li ,-^EM) 5Vh 'OU T -= ^ s-ot switches 2-7 '?tf' 2! xn-ptup -SPKB H7K ^ E5 lOU CSST flASfflSEO Bgure 7.1 Sct>ematic: K>U Soft Switches and Peripheral Address Decodi ng Circuitfy, Input/Output in the Apple lie 7-5 Table 7.1 Address Control of lOU Soft Switct>es. SOFT ON READ OFF ADDRESS SWITCH ADDRESS ADDRESS CONDITION AFTER RESET' KEYSTROBE KSTRB/ NA (NOT APPLICABLE) $C010/ R$COOX W$C01X AUTOSTRB w$cooo W$C001 R$C018 PAGE2 SWITCHES DISPLAY AREA 80STORE* 80COL wscooc W$CO0D SINGLE-RES DISPLAY R$C01F FLASHING TEXT ACTIVE ALTCHRSET W$COOE W$COOF R$C01E TEXT NA $C050 $C051 R$C01A MIXED NA $C052 $C053 R$C01B R$C01C PAGEl PAGE2* $C054 $C055 LORES $C056 R$C01D ANORES* HI $C057 NA OFF $C058 $C059 NA OFF ANl $C05A AN2 $C05B NA OFF $C05C $C05D AN3 NA $C05E ^cosr NA NA OFF CSSTOUT** $C02X $C02X NA NA $C03X $C03X SPKR** AKD NA NA NA NA NA R$C010 NA R$C019 BL' VNOTES: * PAGE2, HIRES, and 80STORE are mechanized identically in the MMU and lOU. The | MMU passes the state of 80STORE tt) MD7 when $C018 is read, and the lOU passes the j state of PAGE2 or HIRES to MD7 wi len .$C01C or $C01D is read. ** CSSTOUT and SPKR are toggled wh en their control addresses are accessed. more than once fronn one KSTRB pulse. My Apple He serial inputs are connected to D7 of the investigations indicate that the delay function is peripheral data bus through the 74LS251 serial clocked by RAS' falling during PHASE 0. input multiplexor. The LS251 is an 8 to 1 multi- 5. CSSTOUT or SPKR tine toggling appears to occur if C02X or C03X is valid in the lOU at plexor whose tri-state output is enabled when C06X' from the peripheral address decoding circuitry RAS' risingduring PHASE 0. The line does not drops low. AO, Al, and A2 from the address bus are actually toggle, however, until after RAS' falls addressing inputs to the multiplexor, so access to during the following PHASE 1, $C06X results in one of eight addressable inputs 6. When the MPU reads the state of an lOU soft being passed to D7. When read access is made to switch, the MD7 enable gate appears to be $C06X, the MMU brings MD IN/OUT' high and the PHASE 0 • Q3' + PHASE 0'»Q3» RAS', which addressed serial input is passed to MD7 for reading is the last three 14M periods of PHASE 0 and by the MPU. Each input can be read at two the first 14M period of the following PHASE 1. addi esses, but programming convention is to read the serial inputs only at the low addresses ($C060— SERIAL I/O HARDWARE $C067). The eight serial inputs and their addresses are: Figure 7.2 is a schematic of Apple's serial I/O Cassette input devices. Most of these devices are connected to the $C060/$C068 outside world through the game I/O socket (J15) Pushbutton 0 $C061/$C069 and the game I/O extension connector (J8). The Pushbutton 1 Pushbutton 2 $C062/$C06A pins on the game I/O socket and extension connector ?C063/$C06B are available to external devices such as joysticks Paddle 0 $C064/$C06C with pushbuttons. Additionally, the four annuncia- Paddle 1 $C065/$C06D Paddle 2 tor signals and the C040 STROBE' are tied directly Paddle 3 $C066/$C06E to pins of the game I/O socket. $C067/$C06F !!5MB! 7-6 Understanding the Apple He ^f :!'(!■ Input/Output in the Apple He 7-7 The serial input multiplexor is a good example of two buttons are pressed. This should cause no prob- how things come in groups of eight or other powers lems in most Apples, but it is something to think of two in digital computers. Three address lines can about if your heavily loaded computer crashes some- be in eight different states, so 8 to 1 multiplexors time when you press a pushbutton. exist for computer designers to use. This naturally The Apple II shift key mod is available via leads to a computer with eight serial inputs. There is jumper pad X6 on the Apple He motherboard. The an operational oddity in the Apple that there are shift key mod evolved as a method for distinguishing four paddle inputs butonly three pushbutton inputs. between upper and lower case keyboard input on the It becomes logical in the light of hardware conven- upper case only Apple II. The modification consists ience. Eight serial inputs minus four timer inputs of connecting the keyboard SHIFT line to PB2. A minus one cassette input leaves room for three program can then tell when ashift key is being held pushbutton inputs. down and thus distinguish between upper and lower A standard paddle set or joystick is shown con- case keyboard entry. If you possess some software nected tothe game I/O socket in Figure 7.2. This which recognizes the shift key mod, but not upper/ illustrates the fact that plugging a standard paddle lower case ASCII from the keyboard port, you can set into the game I/O socket makes eightserial input utilize your software in the Apple He by soldering or output ports inaccessible there. If the paddle set the X6 pad. If you are not currently using the PB2 were shown attached to the extension connector, the input at all, you may wish to solder X6 so you can use same four I/O lines would be utilized. There seems PB2 for your own purposes. With X6 soldered, you to be an unn written law in the Apple world that only can activate all three pushbutton inputs from the PDLO, PDLl, PBO, and FBI will be commercially keyboard. supported . There are exceptions, but th at is the gen- The four paddle inputs (PDLO, PDLl, PDL2, and eral rule. PDL3) from the game I/O socket and extension con- The three pushbutton inputs {PBO, FBI, and nector are tied to a quad timer. These inputs are not PB2) are actually TTL inputs to the serial input high/low binary voltage inputs like the pushbut- multiplexor. They could be used for all sorts of serial tons. For that matter, the timers are not digital input but are normally used for pushbuttons. PBO is devices, although they do have TTL compatible out- also connected to the open Apple switch on the puts to the serial input multiplexor. keyboard, and FBI is also connected to the close The way each timer works is this: first, the timers Apple switch. Both the PBO and FBI lines are are triggered by $C07X access. The outputs of the pulled down to ground by 470 ohm resistors on the four timers then go high and each one stays high for keyboard (Figure 7.4). When open Apple or close a period of time determined by the position of the Apple is pressed, 5 volts is applied to the LS251 paddle connected to its input pin. The paddle knobs input. When the key is released, the LS251 input is are attached to 150,000 ohm potentiometers (varia- pulled below the LSTTL low voltage threshold by ble resistors). Each of these potentiometers is part of the 470 ohm resistor. an R/C (Resistance/Capacitance) network which In addition to the pull-down resistors mounted on determines the pulse width of one of the outputs of a the keyboard, most paddle sets and joysticks will quad timer. They are designed so that the pulse have PBO and FBI pull-down resistors mounted in width in microseconds will be equal to (HP + 100) x them. This is a throwback to the Apple II which did .022 where RP is the resistance of a paddle. Since the not have pull-down resistors installed as the Apple paddles are 150,000 ohm pots, the timer outputs can He does. The value of the pull-down resistors varies be varied from 2 (100 x .022) to 3300 (150100 x .022) depending on manufacturer but will be found to be microseconds. n the 200—1000 ohm range. Since this resistance is The four timer outputs are connected to the serial •n parallel with 470 ohm resistors on the keyboard, input multiplexor so their high/low states can be ;he resistive load on the 5 volt line is 140—320 ohms read by a program. The programming method is to vhen a pushbutton or open/close Apple key is trigger the four timers, then poll the output of the pressed. If a paddle and joystick with 200 ohm pull- pertinent timer in a loop while counting the pro- lown resistors are installed in a game I/O extender, gram loops before the timer resets. Of course, a ind PBO and PBl are pressed simultaneously, the 5 standard paddle set uses only two of the four avail- olt line is connected to ground through a resistance able timers. f 45 ohms. This will cause the current load on the 5 The NE558/SE558 quad timer has a RESET olt line to increase by over 100 m illiamps while the input which brings all four outputs low and inhibits 7-8 Understanding the Apple lie is not an operational amplifier when there is no triggering. This feature is not utilized in the Apple. degenerative feedback. It then becomes a saturated Each timer has its own input trigger, but in the amplifier and, in the case of the Apple cassette are tied to the C07X' line. To input, a threshold detector/signal shaper. Mild apol- Apple, all achieve thefour resettriggers and individual trigger capabilities ogies for all that electronic language, but this isaii would have required extra address decoding circuit- electronic circuit. What it does is this: ry and possibly would have decreased the perfor- mance/cost ratio of the Apple. As it is, the common 1. Blocking capacitor ClO removes any DC com- trigger gives the capability of simultaneously read- ponent ofthe input voltage and makes the pin 2 ing twoor more paddles, and the lack of reset merely input to the LM741 vary above and below 0 requires waiting for timer reset at the beginning of volts. timer polling routines. Unfortunately, neither of 2. The LM741 acts like a threshold detector. If the these realities is supported by Apple firmware. voltage at pin 2 rises above .15 volt (very The timer set up in the Apple is an astonishingly approximately), the voltage at pin 6 will go as cheap way to achieve a 4-channei analog to digital negative as an LM741 can bring it (about input capability. It is possible to obtain variable -4.3V) operating from a -5 volt negative sup- resistors whose resistance is proportional to light, heat, linear motion, rotational motion, chemical ply. Ifthe voltage at pin 2 lowers below -.15 volt (very approximately), the voltage at pin 6 will composition, and probably a lot of other pertinent go as positive as an LM741 can bring it (about things. This means that you can monitor all these -I-4.3V) operating from a +5 volt positive supply. qualities with an Apple computer via the quad Thus, as long as the cassette input exceeds the timer. Of course, it takes a while to read these resis- input threshold, the voltage at pin 6 will be an tances, 22 microseconds per thousand ohms. One the other hand, how much is the temperature going to 8.Q volt p-p squared signal that switches high or low as the input crosses the low threshold or change in a thousand microseconds? The one thing the timers are the least suited to do high threshold. 3. Pin 6 of the LM741 is connected to the serial is the thing they are used quite often for, game controllers for real time arcade type games. A input multiplexor through a 12 thousand ohm sophisticated HIRES arcade game on the Apple resistor. While Al 1-6 is at-^4.3 volts, 4.1 voltsor so is felt at C12-4. While All-6 is at -4.3 volts, requires all of a programmer's skill if the result is the negative input clamp of the LS251 holds the fast paced realistic action. The 6502 in the Apple voltage at pin 4 very close to zero volts, and the executes an instruction every three or four microsec- 12 thousand ohm resistor limitsinputcurrentto onds. Itakes about 500 times as long to perform a about .36 milliamps, typical timer polling routine. Needless to say, pro- gram speed is inversely proportional to the time The neat thing about the cassette input circuit is spent polling the timers. Were the Apple He de- that even when your cheap tape recorder distorts a signed today, without the constraint of compatibil- digital square wave, asquare wave of correct pulse ity with the older Apple II, one would suspect that a width is presented to the input of the serial input modern multichannel quick response analog to dig- multiplexor. Figure 7.3 shows what happens whena ital converter would be used for paddle input rather $30 tape player makes a sine wave outof your square than timers. wave. The LM741 still switches at points separated The eighth input to the serial input multiplexor is in time by multiples of the period of the program the cassette input. The cassette input jack of the loop that stored the information to cassette. Of Apple is connected to a high gain amplifier/shaper. course, there are limits to the distortion which an The amplifier takes the small signal from the ear- Apple can work with. phone jack of a cassette player and converts it to The Apple 11 Reference Manual for lie Only states high and low voltages which can be read correctly that the nominal voltage required at the cassette by the serial input multiplexor. Of course, you can input is 1 volt peak to peak. This is a voltage one still adjust the cassette player volume too high or too would reasonably expect to find at the earphone low, but the amplifier gives you a very reasonable output of a cassette recorder. The cassette output of chance of selecting a volume which works. the Apple is a much smaller voltage, comparable in The cassette input amplifier/shaper is an elec- amplitude to the signal out of a microphone. This tronic circuit that answers the question, "when is an voltage is the CSSTOUT signal from pin 7 of the operational amplifier not an operational amplifier?" lOU reduced by a factor of 121. The CSSTOUT The answer is that an LM741 operational amplifier signal level toggles once every access to $C02X. If >M Input/Output in the Apple Ite 7-9 Square wave which stored digital intormalion to cassette recorder Distorted playback signal is present at cassette input jack HIGH THRESHOLD L LOW THRESHOLD ■ ♦43V •4 3V Originally stored square wave is reproduced at pin6o(theLM741. Figure 73 Cassette Input Wave Shaping. you assume that CSSTOUT swings back and forth diagnostic execution with speaker tones or light between 0 and 3 volts while it is beings toggled, then emi.s.sion from the LED when the speaker is discon- the cassette output jack swings between 0 and .025 nected, The LED thus provides a means of verifying volts (3/121 = .025). diagnostic performance on a motherboard with no The SPKR signal from pin 8 of the lOU is a toggle speaker connected. signal like CSSTOUT, except SPKR toggles when $C03X is accessed. SPKR is applied to a simple APPLE lie KEYBOARD CIRCUITRY audio amplifier which drives the Apple's speaker. The amplifier is necessary because the lOU cannot IVIost readers are aware that the Apple He key- directly drive a. 2 Y^ inch speaker. Current flow board isa considerable improvement over the old through the speaker is in only one direction so the upper case only keyboard of the Apple II, This i.s due speaker action is tense/relax rather than push/pull. more to the deficiencies of the Apple II keyboard Alternate references to $C03X tense the speaker than any exciting features of the Apple lie key- diaphragm and then relax it, but the program can- board. Actually, the Apple lie has an adequate key- not determine whether a $C03X reference causes board that can input all characters needed for tension or relaxation..Thisdampens the possibilities normal text handling applications. It lacks a built- of complex program control of the speaker tension. in numeric keypad and user-definable function In any case, an audio cycle consists of a tension hal f keys, but Apple owners seem to be able to manage cycle and a relaxation half cycle, so two $C03X ref- without them. erences are required per audio cycle. For example. Though the keyboard itself is merely adequate, to program a 1000 Hz tone, you reference $C03X there are some keyboard capabilities hidden in the 2000 times a second. motherboard circuitry. What I'm speaking of is the There is an LED (Light Emitting Diode) con- fact that the keyboard ASCII is mapped in a stan- nected across the speaker jack on the Apple He dard 2K ROM on the motherboard, and that anyone motherboard. However, the LED (CR2) does not who can program a 2K EPROM can define any of normally light because there is not enough voltage the matrix keys in the Apple He to represent what- developed across the speaker primary to cause vis- ever ASCII he desires. Also, there is an alternate ible light emission. The light does glow when SPKR keyboard set which can be selected if you install a IS toggling with the speaker disconnected. You can switch in the right place. With the keyboard ROM see this for yourself by disconnecting the speaker which comes with the American Apple, the alter- plug and holding open Apple and close Apple and nate keyboard layout is the Dvorak (American Sim- pressingCONTROL-RESET. This causes firmware plified) keyboard. But if you burn your own 7-10 Understanding the Apple He input to the keyboard ROM and thus divides the keyboard EPROM, you can create any alternate ROM into a caps locked section and a caps not- layout you desire. FiRure 7.4 is a schematic diagram of the Apple lie locked section. RESET' is distributed to the MPU the lOU, and the peripheral slots. While the key- keyboard circuitry. Tlie source of detail for this board provides a convenient physical location for drawing is the Apple He schematic in the Apple II the RESET key, the other keyboard circuitry is not Rf^frrrncf Maniml for lie Only, except for the key- board itself. I couldn't find a schematic of the affected by RESET'. PBO and PBl are inputs to the serial input multiplexor and are read at $C061 and keyboard but drew Figure 7.4 based on my investi- $C062 (Figure 7.2). The open Apple and close Apple gations ofa real keyboard. keys have no association with the other keyboard There is very little electron ic circuitry on the key- circuitry. board itself, just a bunch of spring loaded, normally There are no matrix keys on the keyboard at the open switches. The majority of the switches are con- nected inan X,Y matrix with eight X lines and ten junctions of YO— ¥5 with X4— X7. These junctions Y lines connected through the motherboard key- are reserved for a numeric keypad which can be board connector to a special purpose IC called a connected to J16 on the motherboard. The numeric keyboard encoder. The keyboard encoder scans keypad could share matrix junctions with the key- through its X drivers while monitoring its Y receiv- board, but the Apple implementation is superior. ers to see if a key is pressed. For example, if the right With separate matrix junctions, the numeric key- arrow key (key 61) is held down, the encoder will pad layout can be defined without regard to the detect this fact because it senses Y9 active when it keyboard layout. activates XO. When a matrix keypress is sensed, the A numeric keypad is shown connected to J16 in encoder produces code that is translated by the Figure 7.4. The characters shown next to the keypad keyboard ROM to ASCII. junctions are those of the keyboard ROMs supplied Of the fiS keys on the Apple lie keyboard, 56 are with the Apple He. There are 24 junctions available connected in the X, Y matrix. Keys not in the matrix for the keypad (4 x 6), and these can be completely perform special functions which will be described redefined by installing a custom keyboard EPROM shortly. As far as the keyboard is concerned, press- in place of the ROM at E12. ing left or right SHIFT or CONTROL pulls the The Apple lie keyboard encoder is a 3600-PRO SHIFT' or CTRi; line low respectively. The CAPS which is a special purpose version of the general LOCK key is similar except that it has a locking purpose 3600 encoder, "rhe general purpose encoder mechanism that alternately locks it closed or is like a masked ROM in that the purchaser specifies releases it to the open position. When CAPS LOCK is which code is output for each junction. Also, certain locked in the down position, the CAPLOCK' line is options can be selected by the purchaser for pins held low and the keyboard ROM produces upper 1—5. These options include internal or external case alphabetic code. Pressing open Apple or close clock oscillator, lockout/rollover' control, output Apple brings PBOor PBl high respectively. SHFT'. complement control, chip enable control, any key CTRL', and CAPLOCK' are pulled up by IK ohm down output, and extra output data bit (BIO). resistors on the motherboard. PBO and PBl are The 3600-PRO is a fixed version of the 3600. pulled down by 470 ohm resistors on the keyboard. Options and output code are standardized, and the The RESET' line drops low if RESET and CON- designer chooses his own code by running the output TROL are pressed simultaneously. This can be from the encoder through a translator ROM or changed so that RESET' drops low if only RESET is EPROM. Fixed features of the 3600-PRO include an pressed by reconfiguring the two jumpers on the internal oscillator controlled at pins 1, 2, and 3, a keyboard. These jumpers can be seen if you remove the keyboard and look at the bottom of the keyboard lockout/rollover' select at pin 4 with internal pull down resistor, uncomplemented outputs, and AKD PC board. Solder the normally open jumper and (any key down) output at pin 5. Other features of the cut the normally closed jumper to make CON- 3600-PRO are fixed features of the general purpose TROL not required tor RESET' to fall. I recom- 3600. mend doing this since the RESET key on the Apple He is recessed and separated from the other keys, so The keyboard encoder has an internal clock oscil- lator whose frequency is set by external components accidentally resetting the computer is unlikely. in the Apple He at approximately 50 KHz. The SHFT' and CTRL' are connected to control inputs switch bounce mask period is also set by an external to the keyboard encoder so that they affect the code component. The bounce mask period is a delay from generated by matrix keypresses. CAPLOCK' is an keypress to data and strobe output in the encoder im_i'\-- Input/Output in the Apple I(e 7-1 1 5V E14 3600 PRO KEYBOARD ENCODER VCC J V(iG W V» V7 V6 Y5 1i Y3 V2 Y1 YO ,24 , 23 NUMERIC KEYPAD - 6 -^ CR CK2 -^ S -, S I^ASK ~l 7 msec MASK BOUNCE CK1 t a ISHl ,Ese 15 T 022 „F si 1^ i'^DELJl ^ t^CR ii- LSPC ISLOT1-35, 7 6) 2» \ p?^ r.se 13 lij. l(MN(U-1S,5l3bl — MDO i^i 45 A'° -* ^^ KBD' » < 50 A7 DATA BUS =^ . C ,<. M-? (J-;! B ^ v.J^ c ::; X4? z ^ — MD! ENKBD' -NC Htl? S L^ i^i K^i^ ji' G.? F -JT ~MD3 "^ 51' 4 A6 ^•MD4 ^ 7 7 S 3 & , ESC A4 2716 2316 A9 EPflOM A3 ROM/ 05 - — M05 LSHFT (43) r^ AO "17 11 A2 11 A5 ElZ RSHFT(54j| (7.21 AI A10 CTRL (30) SHIFT 5V CTRL -o-'-'o RESET (151 VCC -MP- H3 8.4 2.7 6 CftPS AN2 LOCK IK) r VPP OAPL (571 -(7 2) CAPLOCK' -(7.2) 5V-> — t O-^ (591 CAPL^ IK 470 , T (AUX-291 is.51 KEYBOARD ENVID' WJTES: ID SPC. njh(, ESC. lelt, ? oi 341|2)^!]32-B hwboard BOM (early Ap keybaaid llel were ROM (later byApple replareb lie).Is" - "^ - ■"*" - ->•"■'—"- righl. Figure 74 Schematic: App^e lie Keyboard Circuitry. y-l 2 Understanding the Apple lie before the data ready strobe goes high. This is far which prevents interpreting switch bounce as mul- more than the 450-nanosecond address to data prop- tiple keypresses (see Figure 7.5). According to the agation delay of the keyboard ROM. Knowing this nomograph in the data sheet, a C71 value of .022 it seems strange that Apple took pains to delay microfarads should result in a 7-millisecond mask KSTRB a couple of MPU cycles in the lOU. Perhaps period in the Apple He.* However, I measure the they were misled by the 3600 data sheet timing mask period in my Apple Heat 13 milliseconds, so I diagram into thinking the delay is necessary so that compromise and say that switch bounce in the Apple lie is masked for approximately 10 milliseconds. ASCn from the keyboard ROM will be certain to Figure 7..'i is a timing diagram from the General precede KSTRB. Instrument AY-5-,%()0 data sheet. As the diagram Thfe AKD output of the encoder goes high when shows, the data ready strobe is output only after a any matrix key is pressed and stays high until all key has stopped bouncing and the mask period has matrix keys are released. This AKD output is routed to the 10 U where it enables the AUTOSTRB cir- passed. The strobe is a 20-micro5ecoiid (one clock- pulse) positive jiulse which is output once for every cuitry (Figure 3.8) and is pasSed to MD7 when kevpress. This strobe is the KSTRB input to the $C010 is read (Figure 7.1). Note that the AKD line goeshigh immediately without waiting for the mask idu which sets the KFA'STRORE Softswitch (Fig- ure 7.1) and resets the auto repeat delay function period to pass. This means that there is a period of (Figure ;i«). approximately 10 milliseconds after a key is pressed It can be seen in Figure 7.5 that the data output of when a program will sense AKD active when read- the keyboard encoder is sot up. sometime in the clock ing $C010, but when the keyboard ASCII will not period preceding the data ready strobe. Actually, yet be updated to that of the current keypress. For Figure 7..^ is ext^>mei.^■ misleading, because the this reason, programs should normally wait until data output is set up very quickly after the begin- KEYSTROBE is set before interpreting the key- ning of the clockpulse period preceding the data board ASCII. Using AKD for this purpose could ready strobe. In the Apjile lie, the encoder data is easily lead to errors. actually set u]i for api)roximately 20 microseconds The lockout/rollover' pin of the encoder in the *(;i']icr;il InstriitiH'iit pulilii-aliim ROM ■'.. ,\Y-.')-:!(ll)() Keyboard Apple He is open. Since the line is pulled low inter- nally. Apple lie keypresses "roll over." This means SWITCH SWITCH RELEASE CLOSURE MINIMUM SWITCH CLOSURE --4 [— 90 CLOCK CYCLES BOUNCE ^ ^ STROBE ,1 , SWITCH _J DELAY KEY CLOSURE FOUR iTl CYCLES CLOCK DATA REAOf LEVEL PULSE STROBE x: n KEY ROLLOVER DATA OUTPUT ANY KEY DOWN OUTPUT I '— RESETS AT FIRST Xq AFTER FIRST X| Yi 1 RESUME n KEY SCAN FOR- ROLLOVER RESUME SCAN FOR n KEY LOCKOUT MINIMUM SWITCH CLOSURE = SWITCH BOUNCE + (90x^1 + STROBE DELAY + STROBE WIDTH MAXIMUM DETERMINED BY EXPECTED EXTERNAL C DETERMINED BY FREQUENCY MINIMUM TIME OF OPERATION REQUIRED BY (EXTERNAL RC) EXTERNAL CIRCUITRY Figure 75 Timing Diagram from AY-5-3600 Keyboard Encoder Data Sheet (Courtesy of General Instrument Corp). Input/Output in the Apple He 7-1 3 that when a key is pressed while another key is held control/shift/both operation is the inverse of what down, the code for the new key is placed on the the 3600-PRO data sheet indicates because the data encoder output line after the mask period. With sheet assumes that the control and shift inputs to the lockout, code from new keypresses are locked out encoder are active when high.* In the Apple, the until the old key is released. If you would like lockout control and shift inputs to the encoder are active when low. rather than rollover on your Apple lie, justjumper pin 4 of your encoder to +5 volts. At the same time that mode ident is latched at The following quote from the AY-5-3600 data B2B3, unique code for the X,Y junction of the sheet describes n-key rollover operation, "When a matrix key that is pressed is latched at match occurs, and the key has not been encoded, the B1B4B5B6B7B8B9. For example, if the XO-YO switch bounce delay network isenabled. If the key is junction key is pressed, 0000000 is latched at still depressed at the end of the selected delay time, B1B4B5B6B7B8B9. the code for the depressed key is transferred to the You can represent the XO-YO junction as XY = 00 output data buffer, the data ready signal appears, a or the X5-Y4 junction as XY = 54 (decimal). When one is stored in the encoded key memory, and the you do this, the B1B4B5B6B7B8B9 code for any scan sequence is resumed. If a match occurs at keypress is the binary equivalent of the decimal another key location, the sequence is repeated, thus number XY. The 7-digit binary equivalent of 54 is encoding the next key. If the match occurs for an 0110110, so when the X5-Y4 switch is pressed, the already encoded key, the match is not recognized. 3600-PRO latches 01 10110 at B1B4B5B6B7B8B9. The code of the last key encoded remains in the The BlB4B5B6B7B8B9.B2B3code from the key- output data buffer." The output of the keyboard encoder is latched AlAO board encoder islines address applied of to thethe ASA 7A6A5A4A3A'2, keyboard ROM. Since information which cannot be modified by the B1B4B5B6B7B8B9 is the binary equivalent of XY, MPU. When a key is pressed and the mask period the ROM address for any matrix keypress is equal to passes, the code for that matrix junction is output XY X 4. For example, the "J" key is located at the from the 3600-PRO. This code addresses the key- X2-Y6 junction so the address for "J" in the key- board ROM, and the ASCII can be read at the output board ROM is 26 X 4 = 104 - $68. Therefore, the of the keyboard ROM no more than 450 nanoseconds keyboard ROM contains ASCII for SHIFT/CON- after the code from the encoder becomes valid TROL-J at $68, CONTROL-J at $69. SHIFT-J at (assuming 450-nanosecond ROM or EPROM). This $6A. and ALONE-J at $6B. ASCII can be read at any time at $COO0— $C01F The two most significant addressing bits of the before another matrix key is pressed and the new keyboard ROM, A9 and AlO, are connected to the code is val id at the output of the encoder long enough CAPLOCK' and ENVID' (AN2 if Rev A) lines. to propagate through the keyboard ROM. What this means is that there are four separate sets A Slot 1 peripheral card can disable keyboard of ASCII in the keyboard ROM, two of which are ROM response to $0000— $COIF by pulling commonly used. The two which are commonly used ENKBD' high. This deactivates the chip enable are the caps locked, standard set ($000— $13F) and input to the keyboard ROM. It is therefore possible the caps unlocked, standard set ($200— $.X'?F). Con- for an alternate keyboard interface card in Slot 1 to tinuing with the previous example, the caps locked, steal response to $C000— $C01F. However, most standard addresses for J are $68— $6B, and the caps alternate keyboards designed for use with the Apple unlocked, standard addresses for J are $268~$26B. He do not plug into Slot 1 but plug directly into the The caps locked set is almost identical to the caps motherboard keyboard connector. The capability of unlocked set. The only difference is that the ALONE disabling the keyboard ROM from Slot 1 is probably code for the 26 letters of the alphabet is upper case, meant to support some motherboard production not lower case. Thus, the CAPS LOCK key is used to checkout test apparatus. force alphabetic characters to upper case without The output of the 3600-PRO forms the word affecting the numeric and special characters. B1B4B5B6B7B8B9,B2B3, where B2B3 is the shift/ control mode ident and B1B4B5B6B7B8B9 is the junction code. After the mask period when a *There are internal pull down resi.stors on the control and shift matrix key is pressed, B2B3 is latched to 11 nor- inputs to the 3600 so there is good rea.son for the data sheet assumption that these lines are active when high. The internal mally, 10if CONTROL only is also pressed, 01 if resistance values are very large, however, and the IK mother- SHIFT only is also pressed, and 00 if both CON- board resistors puli the SHFT' and CTRL' lines very close to 5 TROL and SHIFT are also pressed. This normal/ volts when neither SHIFT or CONTROL is pressed. 7-14 Understanding the Apple He including Dvorak as an alternate layout, it is good The two sets of keyboard ASCII which are not that they quickly took steps to conform to the pro- commonly used are the caps locked, alternate set ($400— $53F) and the caps unlocked, alternate set The posed change standard. to the keypad layout looks like an (1600— $73F). In American Apples this alternate afterthought. The SPACE and ? of the B ROM were set contains the Dvorak (American simplified) key- deleted to make room for up and down arrows in the board layout. Dvorak is a superior keyboard layout C ROM. I assume that Apple makes the C ROM which allows faster touch typing than the QWERTY available to anyone who buys a keypad which sup- layout, but is rarely used because the QWERTY ports the newer layout. Of course, any keypad layout is the English lang-uage standard. It is also manufacturer can sell a keypad with any 4 x 6 or rarely used in the Apple He because many owners don't even know that Dvorak is built in, and they smaller layout and make it work in the Apple He by wouldn't know how to access it if they did know it including an inexpensive custom keyboard ROM was there. An application note at the end of this which the buyer can plug into the motherboard. chapter shows how to install a switch that wil I allow T^ble 7.2 tells a few other interesting tales if you the operator to select the standard keyboard layout look carefully. For one thing, the Apple He key- or the alternate layout. board iscapable of producing every ASCII code In Apples built for use in foreign countries, the from $0— $7F when used with the keyboard ROM standard keyboard set is the same as that of Ameri- that comes with the computer. CONTROL-2 and can Apples. The alternate set, however, corresponds CONTROL-6 appear to have been made to corre- to the normal keyboard layout for the primary lan- spond toASCII $00 and $1E specifically to attain guage of that country. Additionally, on export this capability. motherboards designed for use in countries using Another featu re of keyboard operation that can be the PAL television system, a simple ALTCHR line gleaned from Ikble 7.2 is that, of the special function selects between the standard and alternate key- matrix keys, only ESC and DELETE produce board and videocharactersets without conflict with uniquecode{excludingnumeric keypad keys). TAB, the ENVID' line (see Figure 8.6). RETURN, left arrow, right arrow, down arrow, Table 7.2 summarizes the contents of the key- and up arrow produce code that is identical to that of board ROM of American Apples. This table is CONTROL-I. CONTROL-M, CONTROL-H, CON- indexed by XY matrix number, so it should be very TROL-U, CONTROL-J, and CONTROL-K, respec- useful to persons wishing to program a custom key- tively. board EPROM. ASCII output for all four keyboard sets and all four mode idents is shown, as well as a Keyboard Operational Summary base address for each key showing the ROM address Circuits related to the keyboard operation have of the caps locked, standard, SHIFT/CONTROL been covered in other chapters and sections of entry. UnderManditig the Apple He, This includes the Apple has used two different versions of the key- board ROM in its American Apple. The earlier AUTOSTRB circuitry of Figure 3.8, the KBD' gen- eration logic of Figure 5.13b, and the KEYSTROBE Apple He's came with the 341(2)-0132-B ROM, and soft switch and AKD reading circuitry of Figure more recent Apple lie's come with the 341(2)-0132-C 7.1. So the reader will not have to search the entire ROM (Apple's part numbers)*. There is very little book for keyboard reference material, a summary of difference between the B and C ROMs— just some keyboard operational features is presented here. minor changes to the Dvorak special characters and the numeric keypad characters. Those matrix junc- 1. ASCII for any matrix keypress becomes avail- tions inTkble 7.2 which have a (B) entry and a (C) able for reading by the MPU approximately 10 entry are those that were changed in the C ROM. milliseconds after the key is pressed. The apparent reason for changing the keyboard 2. Apple He keys roll over so that if a key is pressed ROM was that the quote, colon, and question mark when another key is held down, the ASCII for keys in the Apple Dvorak layout were not in accor- the new mask key will be read by a program after the dance with a standard Dvorak layout being pro- bounce period, posed by the American National Standards Insti- 3. When an address in the $C00O— $C01F range is tute. Since Apple has taken on a leadership role by read, the MMU brings KBD' low during ♦Apple documentation and the copyright notice in the keyboard PHASE 0 to gate the ASCII of the last matrix ROM refer to the part number as 341-0132, However, the ROM in my Apple He is marked 342-0 132-B keypress MD6 of thefrom data the bus.keyboard ROM to MDO— Input/Output in the Apple Ile 7-1 5 4. The AKD line goes high while any matrix key is fill in the blanks." One never knows what lurks held down. AKD is routed to the lOU, and the beneath the lid of an innocent looking Apple. lOU places the state of AKD (delayed 2—3 The capabi lities of the peripheral slots seem more MPU clock periods) on MD7 of the data bus if clear when you look at the connected signals in $C010 is read. For about lOmilliseconds after a groups. Figure 7.6 illustrates the peripheral slot key is pressed, the MPU will sense AKD high at connections— grouping the signals functionally. The $C010 but will read outdated keyboard ASCII power supply voltages, for instance, are all grouped at$COOO-$C01F. together. One quickly sees that all of the power 5. The KSTRB line goes high for approximately 20 supply voltages available in the Apple are also microseconds one time for each matrix key- available at the peripheral slots. press. There is a bounce mask period of about 10 Paramount in importance among the peripheral milliseconds between the keypress and the slot signal s are the address bus with R/W , the data KSTRB pulse. The KSTRB pulse occurs kbout bus, and the timing inputs. Consider what we know 20 microseconds after the ASCII for that key- about MPU control ofthe Apple. All data transfer is press is available for reading by the MPU. over the data bus under control of the address bus KSTRB is routed to the lOU where it is delayed during PHASE 0. All I/O control is via the address 2—3 MPU clock periods before it sets the bus. The correct inference is that you can duplicate KEYSTROBE soft switch. any motherboard action with a peripheral card 6. If a key is held down for 534—801 milliseconds design. This gives you an idea of the variety of tasks (depending on the relationship of the keypress that can be accomplished. Of course, most of the to flash counter bit F3), the lOU starts to gener- things people are going to stuff into Apple pe- ate internal auto repeat strobes at the rate of 15 ripheral slots haven't even been dreamed of yet. Hz. These AUTOSTRBs set the KEYSTROBE The peripheral slot data bus is connected to the soft switch as if the operator was pressing a key main data bus through the bidirectional driver, B2. repeatedly at a very fast rate. Both the The purpose of this driver is to supply the data bus AUTOSTRB delay and frequency are functions current needs of a variety of peripheral cards that of the display vertical scan rate (Figure 3.8). might be installed. Because of the d river, the load on 7. Either AKD or KSTRB clears the AUTOSTRB the main data bus does not fluctuate as the pe- delay generator in the lOU so that pressing any ripheral slot load is varied, and a heavier peripheral matrix key interrupts the auto repeat function. slot load can be tolerated than could be without the 8. The KEYSTROBE soft switch is set by KSTRB driver. or AUTOSTRB. It is reset at power up or by The MMU provides directional control to the MPU access to $C010 or write access to $C01X. bidirectional driver via the MD IN/OUT' line. The Its state is read via MD7 of the data bus when nature of this control is such that the driver is opera- read access is made to $COOX. tionally transparent. In other words, the operation 9. Programmable functions are: is just about the same as if the peripheral slots were ADDRESS connected directly to the data bus. Simply put, when FUNCTION data needs to be transmitted from the slots or serial K?CO0X Read KSTRB and ASCII R$C010 Read AKD and ASCII; input multiplexor to the data bus (such as when a reset KEYSTROBE read access is made to a DEVICE SELECT' R$C011-$C01F Read lOU or MMU soft address), the MMU brings MD IN/OUT' high dur- switch and ASCII ing PHASE 0 so that direction of the driver is in to the data bus. Otherwise, the MMU leaves MD W$C01X Reset KEYSTROBE The OE' low.* IN/OUr input to the bidirectional driver is always PERIPHERAL SLOT CONNECTIONS low except during PHASE 1 of write cycles. Actu- It is hard to know where to start talking about ally, the Apple He would work very well if OE' was )eripheral slot I/O. You can do so much from the simply grounded. The only effect I can see of isola- ting the data bus from the peripheral data bus dur- lots. They are as versatile as modern microeom- ing PHASE 1 of write cycles is to prevent video data ::)uter architecture with full connection to the from motherboard RAM from beingavailable at the .iddress bus and data bus. It's like someone designed ♦See Chapter 5. MEMORY MANAGEMENT IN THE APPLE - really neat computer but on the blueprints drew He. KDB' and MD IN/OUT' for a complete discussion of the '.even empty squares with the message, "user, please MD IN/OUT' signal. 7-16 Understanding the Apple lie NO Table 72 Apple Me Keyboard ASCII (1 of 2). SH CAPS cr CM SHLOCK iuT LOCK BO SO 31 21 31 IB IB SW CAPS CAP UXK XY ADDMR* BO LOCKAL SH CT SH DVORAK BO CT 40 IB AL IB 16 21 31 RO QWERTY 2 @ m 01 ESCAPE CT IB IB IB IB IB IB AL IB KSCAPE IB 00 IB 34 34 23 24 00 40 3233 BO 31 21 31 41 ? i 24 21 33 24 34 01 $00i} 21 @1 31 31 21 31 33 21 33 23 02 $004 IB 02 40 IB 00 21 00 00 40 32 3 # 00 24 32 25 00 03 9008 21 5E 36 03 43 5# 00 23 33 23 33 32 23 33 23 33 23 IE 23 36 IE 25 35 04 $00C 26 34 04 24 34 24 24 34 34 35 05 $010 07 IE 5E 34 36 IE IE ?6 IE 5E 26 IE 26 37 05 5 % IE 06 06 5014 25 35 35 25 35 25 5E 35 59 %( 25 2A 25 35 35 2A 3B 07 08 S018 7 & 26 37 26 37 26 37 24 7 & 28 39 26 37 2F 37 28 39 08 09 S01C 25 38 38 2A 2A 38 2A 38 38 2A 38 2A 38 9 ( ' " (C) 09 10 S020 2A 2B 39 28 39 28 39 28 71 39 28 28 39 " 37 26 09 a0 16 $024 TAB 6 09 09 09 09 09 TAB 09 09 37 09 09 22 09 3F 2F 09 11 17 5028 0 8 * 11 11 51 51 09 11 11 51 71 / ? (B) 3F 3F 2F 22 3F 20 3C 272C 11 17 $02C Q 09 11 11 51 11 11 51 77 72 22 27 22 27 27 3E 2E $02C 57 17 17 57 06 2P 30 19 50 70 12 18 5030 W 51 45 10 20 3C 10 59 20 13 19 E 05 05 05 45 65 2E 3E 2E 3E 06 2E 46 66 14 20 $034 R 17 12 17 12 45 57 52 52 12 05 12 75 P. > 8 * 50 50 03 10 10 59 79 15 5038 Y 59 59 19 19 59 79 F 3E 22 19 19 15 06 46 46 06 16 503C T 54 54 14 14 54 74 Y. < 19 6 '19 3C 43 47 67 21 14 14 59 19 $040 15 52 9 09" 17 23 U 55 49 49 55 15 G 07 12 47 47 07 07 43 063 18 24 $044 I 15 09 09 09 49 69 C 05 03 43 03 03 19 20 25 31 $048 $04C 0 A 09 0F 4F 4F 41 41 0F 01 0F 4F 6F 10 53 73 55 61 41 A R 07 12 52 01 01 41 41 n u Ji 41 52 61 72 01 01 45 65 21 33 $050 0 0F 01 01 44 44 04 04 64 E 04 04 05 04 45 45 05 22 23 32 $054 5058 S 13 13 53 48 53 46 13 13 44 0 0P 0F 4F 4F 15 08 4F 0F 44 64 6F 36 H 08 08 08 08 48 68 D 04 44 44 04 04 ^ 9 34 $05C F 6A 13 55 75 24 06 06 46 48 06 06 46 66 U 15 15 55 55 15 0F 49 69 25 35 $060 G 47 47 67 I 07 09 09 49 54 49 09 09 48 68 $064 26 37 $068 J 0A 3A 07 0A 4A 4A 0A 0A 4A H 08 08 48 48 08 05 27 38 K 0B 3B 4B 4B 0B 07 0B 07 4B T* 14 14 54 14 14 54 74 28 40 $06C 0B 3A 3A 3B 47 3B 3A 6B 7A S " (B) 13 13 53 53 13 53 73 $070 29 39 L 0C 0C 4C 4C 3B 0C 40 7A 60 N 0E 4E 4E 0E 4E eE 30 44 $074 Z lA lA 5A 5A lA 0C lA 5A 22 27 22 27 22 27 22 27 $078 30 44 5078 Z lA 03 lA 5A 43 5A lA 5A 78 58 ; : (c) 0E3A 3B 3A 3B 0E 3A 3B 31 45 X 18 18 58 58 18 18 3A 3B 507C 56 Q 11 11 51 51 11 11 51 71 32 46 $080 c 03 43 03 03 43 63 J 0A 4A 4A 18 0A 18 4A 6A 33 V 16 16 56 16 16 56 76 18 18 47 $084 K 0B 0B 4B 4B 0B 0B 4B 6B 34 48 B 02 42 42 02 02 42 62 X 16 $088 4D 58 58 0A 35 49 N 0E 0E 4E 4E 0E 4E 6E B 02 02 42 42 02 02 42 62 0A 36 50 $08C $090 M 0D 02 0D 4D 0E 0D 4D 6D M 4D 58 78 0D 0D 4D 6J) 37 51 $094 3C 2C 2E 3C 2C 3C 2E 20 3C 2C W 17 17 lA 17 17 38 52 $098 3E 3E 2E 3E lA 57 57 ., >< 2F 0D 3E 2E V 16 16 56 56 16 57 5A 77 39 53 3P 3F 2F 3F 2F 3F z lA 0D 5A lA 56 7A_76 40 KP $09C / 2F 2F 2F 2F 08 0D 41 S0A0 KP S0A4 left(B) / ? 2F 2F 2F 2F 30 08 08 /left(B) 2F 2F 4D 2F 2F down(C) 08 08 0A 08 08 08 down (C ) 08 08 08 08 08 08 2F 2F 41 KP 0A 30 0A 0A 0A 0A 2F 0A 2F 0A 0A 0A 0A 2F 42 KP $0A4 $0A8 0 30 30 30 30 30 30 0 5A 30 30 08 08 0A 30 30 32 30 0A 0A 43 KP 1 31 31 31 31 31 31 31 31 1 31 31 31 31 30 30 0A 44 KP ?0AC S0B0 2 32 32 32 32 32 -B- 32C 32 32 2 32 32 32 32 32 45 KP 3 33 33 33 33 33 33 33 5C 33 3 33 33 33 31 31 46 29 50B4 ¥0Ba IC IC 7C 33 33 0A 32 31 32 ■ijti 5C IC IC 7C IC 5C 30 IC 10 \ 1 \ 1 31 33 33 BO ALOHB IC 7C AL 1 33 standard 7C 5C an SHIFT CONTBOL A^a $00n for capa lock, $20n for no Lock,, standard CT BOTH $40n for capa lockr Dvorftk KP KEYPM) -9132 560n foe ho lock, Dvorak KEY 341(2) -0132- KEYBOARD (B) m 341121 ROM wliere n •» 0 for BOTH IC) ■ KEYBOARD ROM 1 for COHTROL 2 for SHIFT 3 for ALONE Input/Output in the Apple He 7-1 7 Table 72 Apple lie Keyboard ASCII (2 of 2). SH CAPS LOCK NO CAP LOCK CAPS LOCK NO CAP LOCK 0 ) XY * ARDODMR* BO CT SH AL BO CT SH AL DVORAK BO CT SH AL BO CT SH AL =QWERTY + 13 2B 3D 2B 30 ID ID 7D 5D ID ID 70 5D 47 0 ) 2B 3D 2B 3D- ] ) 29 30 29 30 48 $0BC 29 30 29 30 29 30 29 [ ( 29 30 29 30 11 $0C0 IF IF 5F 2D 49 12 IF IF 5F 2D IB IB 7B SB 1 R 1 R 7Fl c;tj 50 KP $0C4 '-V) --~ 29 29 29 29 3D 29 29 29 29 ESC (B) 29 29 29 29 29 29 29 29 $0C8 ESC (B) ) IB IB IB IB IB IB IB IB 51 KP IB IB IB IB IB IB IB IB 51 KP $0CC 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B up (C) up (C) KP ?0CC 4 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 52 $0D0 4 53 KP 5 35 35 35 35 35 35 35 35 5 35 35 35 35 35 35 35 35 54 KP ?0D4 6 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 $0D8 70 6 55 KP 7 37 37 37 37 37 37 37 60 37 7 37 37 37 37 37 37 37 37 56 56 ?0DC 7E 60 7E 60 7E 60 7E « -Sr 7E 60 7E 60 7E 60 7E 60 26 50E0 P 10 10 50 50 10 10 50 5B 0C 0C 4C 4C 0C 00 4C 6C 57 $0E4 L= + 58 27 $0E8 [ { IB IB 7B 5B IB IB 7B 5B ; : (B) 3A 3B 3A 3B 3A 3B 3A 3B 58 27 [ { IB IB 7B 5B IB IB 7b 3F 2F 3F 2F 3F 2F 3F 2F $0E8 / ? (C) "■2A ID ID 7D 15 2a Ih 59 28 ID ID 70 5D 2A 60 : } 5D 2B 3D 2B 3D 2B 3D 2B 3D KP $0EC * 2A 2A 2A 2A 2A 2A 2A 2A * up 61 KP 50F0 15 15 15 15 15 15 15 08 rght(B) 2A 2A 'IK 2K rght(B) left(C) 15 15 15 15 15 15 15 15 61 KP $0F4 left(C) 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 62 KP ?0F4 38 38 38 38 38 38 38 38 $0F8 8 38 38 38 38 8 38 38 58 38 63 KP ¥0FC 9 u 39 39 39 39 39 39 39 2E 39 9 39 39 39 39 39 39 39 39 64 KP 5100 • p 2E 2E 2E 2E 2E 2E 2E . 2E 2E 2E 2E 2E 2E 2E 2E 65 KP 5104 + 2B 2B 2B 2B 2B 2B 2B 2B + 2B 2B 2B 2B 2B 28 2B 2B 66 42 RETURN 0D 0D 0D 0D 0D 0D 0D 20 RETURN 0D 0D 0D 00 5108 0D 0D 0D 0D 0D 67 63 0B 0B 0B 0B 0B 0B 0B 0B 08 0B 0B 0B 0B 0B 0B 0B 68 58 $10C 20 20 20 20 20 20 20 20 41 ?110 SPACE 20 20 20 SPACE 20 20 20 20 69 5114 1 H 22 27 22 27 22 27 22 27 - IF IF 5F 2D IF IF 5F 2D 70 KP ? (B) ? (B) $118 3F 3F 3F 3F 3F 3F 3F 3F ESC (C) 3F 3F 3F 3F 3F 3F 3F 3F 70 KP ESC (C) IB IB IB IB IB IB IB IB $118 SPCE{B) SPCE(B) IB IB IB IB IB IB IB IB i 71 KP 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 71 KP $11C 72 KP ?11C rght(C) 15 15 15 15 15 15 15 15 rght(C) 15 15 15 15 15 15 15 15 $120 ( 28 28 28 28 28 28 28 28 ( 28 28 28 28 28 28 28 28 73 KP - 2D 2D 2D 2D - 2D 2D 2D 2D 2D 2D 2D 2D $124 2D 2D 2D 2D 74 KP RETURN 0D 0D 0D 0D 0D 0D 0D 0D RETURN 0D 0D 0D D0 0D 0D 0D 0D 75 $128 KP $12C / 2C 2C 2C 2C 2C 2C 2C 2C 2C 20 2C 2C 2C 2C 2C 76 14 DELETE 7F 7F 7F 7F 7F 7F 7F 7F r DELETE 7F 7F 7F 7F 77 62 5130 7F 7F 7F 7F down 0A 0A 0A 0A 15 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 78 60 5134 down $138 left 08 08 08 08 2C 08 08 08 08 left 08 08 08 08 08 08 08 08 79 61 30 57r ** §13C right 15 15 15 15 15 15 15 right 15 15 15 15 15 15 15 15 ^140 J 20 20 20 4A 20 20 20 4A J 20 20 20 4A 20 20 20 4A 31 Itir 32 S144 0 20 20 4F 20 20 20 4F 20 0 20 20 4F 20 20 20 4F 20 33 '34 5148 H 20 48 20 20 20 48 20 20 H 20 48 20 20 20 48 20 20 ** ■kit 514C U 4E 20 20 20 4E 20 20 20 N 4E 20 20 20 4E 20 20 20 35 $150 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 J6 ** 5154 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ** 5158 M 20 20 20 4D 20 20 20 M 20 20 20 4D 20 20 20 4D 17 J8 ♦ it 515C A 20 20 41 20 20 20 41 4D 20 A 20 20 41 20 20 20 41 20 i9 ** $160 C 20 43 20 20 20 43 20 20 C 20 43 20 20 20 43 20 20 S164 D 44 20 20 20 44 20 20 20 D 44 20 20 20 44 20 20 20 XY =■ 80-69 are not used in the Apple lie because xa of the keyboard encoder is not Gtjnnected. In the Apple ROMs, this area contains the name, "JOHH MACD", short for John HacDougall. Addregoes ?16fi-SlFP, 536S-53FF, S56e-S5FF. and $76e-S7PF are not used because the keyboard enco<1er supports 90 matrix junctions, not 12S. In Apple ROMs, this area ia filled with $AH, except for $7D8-S7Ff which oontaitis this or a aimilar meooage: "341-0132B COPYRIGHT APPLE COMPUTER 1982". 7-1 8 Understanding the Apple lie I/O SELECTS' (7,1) .A* (3,9) CLKEN' VIDEO SYNC (8.S) DMA PRIORITY CHAIN NC GR*Z (8,51 Q] INTERRUPT PRIORITY CHAIN NC (7,4| ENKBD'* COLOR REF (3,9) DEVICE SELECTS' (7,1) NOTES: '— ' present in Revision Bconnecte only. d in revision A.: m Slot 7 pin 23 is not Figure T& Schematic; Apple lie Peripheral Slot ConnecHont. Input/Output in the Apple lie 7-19 peripheral slots when PHASE 0 rises during write Controller (Figure 4.7) to successfully steal a cycle cycles. I suspect that Apple did this for compatibil- from the old DMA based Softcard in an Apple He. ity with the Apple II although I might be missing Slot 1 has two signals connected which are not something they ran up against in the design. available at the other slots, ENKBD' and CLKEN'. A number of timing signals are available at the These are present primarily for diagnostic and test- peripheral slots. You can't have too many of these ing purposes, but innovative peripheral card designs signals at hand to help synchronize peripheral card could make good use of them. When ENKBD' is functions to the motherboard. PHASE 1. Q3. 7M, high, the keyboard ROM is inhibited and the other COLOR REFERENCE (Slot 7), 6502 SYNC, and devices can place data on MDO— 6 of the data bus video SYNC (Slot 7) are present. Notably absent when read access is made to $C000— $C01F. When are 14M, HAS'. CAS', and an INHIBIT' priority the CLKEN' is high, the motherboard 14M signal is chain. With signals like these begging to be con- disabled, and a card in the auxiliary slot can inject nected, it's surprising that pins 19 and 35 of Slots 2 an alternate master clockpulse reference onto the through 6 are not connected. 14M tine. If, as normally is the case, ENKBD' and Important 6502 control inputs are connected to CLKEN' are not connected on the Slot 1 card, moth- the peripheral slots. These are IRQ', NMF, RESET'. erboard pull-down resistors pull these lines low so and RDY. They are connected in a wire-OR config- the affected circuits can function normally. uration with 3300 ohm pull-up resistors so any card The USERl' line of the Apple II is not present in can cause an interrupt, reset the Apple, or stop the the Apple He. This was a hardware means by which 6502 via the READY line. The RESET' line is also any peripheral card could disable all I/O address connected to the keyboard RESET key and to the decoding in the $C000— CFFF range by pulling a lOU which responds to RESET' in addition to gen- single line low. In the Apple He, motherboard or erating anegative RESET' pulse when the Apple is peripheral card resident programs can disable I/O first turned on. decoding in the $0100— $CFFF range using the Other wire-OR lines from the peripheral slots are INTCXROM. SL0TC3R0M, and INTC8R0M soft the DMA' line and the INHIBIT' line. DMA' al lows switches, but the capability of inhibiting DEVICE a peripheral card to isolate the MPU from the SELECT' and other $COXX decodingdoes not exist. address bus and data bus so it can gain control of the Pin 39, the USERl line in the Apple II. is the 6502 Apple ables for MPUfast I/O or other purpose. INHIBIT' and dis- SYNC line in the Apple He. Having 6502 SYNC communication with motherboard present is very helpful in hardware applications auxiliary card memory, and opens up $0000— such as execution of single instructions and identify- $BFFF and $D000— $FFFF addressing for any ing op codes on the data bus. For example, it is sort of peripheral card response.* Note that between possible for a peripheral card in any Apple lie slot to INHIBIT', INTCXROM, SL0TC3R0M, and the detect the execution of an RTI instruction by looking Slot 1 ENKBD' line, provisions exist for assigning for SYNC high and $40 on the data bus when all addressing in the $0000-$C01F and $C090- PHASE 0 fails. By detecting 6502 instructions in $FFFF ranges to the peripheral slots. this manner, it is actually possible for peripheral The Apple He is different from the Apple II in cards to respond directly to 6502 program instruc- that 3300 ohm resistors are used to pull up the pe- tions. ripheral slot wire-OR lines as opposed to the 1000 The DEVICE SELECT's, I/O SELECT's, and ohm pull-up resistors of the Apple 11. This value I/O STROBE' are address decoded signals which may have been swi tehed becau se th e 6502 data sheet identify addresses on the address bus in the ranges specifies 3000 ohm resistors for 6502 wire-OR lines, assigned to the peripheral slots. These address but it sure lengthens the rise time of the wire-OR ranges could have been assigned by convention only. lines. In fact, the 3300 ohm resistors cause such slow For example, a Slot 1 peripheral card could easily switching that some peripheral cards may require a decode the $C09X address range without the aid of parallel pull-up resistor on a wire-OR line to operate its DEVICE SELECT' input, but then how could properly in the Apple He. I found that this was you operate that card in a slot other than Slot l?The lecessary on the DMA' line to enable D MAnual card would have to have switches to configure it for different slots. Also, having DEVICE SELECT' decoded on the motherboard lends the force of INHIBIT' alsodisables $C100-$CFFF motherboard ROM, so hardware reality to the convention that $C09X ny peripheral card can use INHIBIT' to (rain access to $C100— CFFF addresses that are configured for motherboard ROM esponse. belongs to Slot 1. This is fairly important consider- ing the diversity of .sources for Apple peripheral 7-20 Understanding the Apple He EPROM programmers with driving programi cards. Needless to say, decoding the address ranges on the motherboard also reduces the chip count of stored in firmware. It is important to remember that any prograii] most peripheral cards. can disable the I/O SELECT' signals and I/C The DEVICE SELECT' input to each peripheral STROBE' by manipulating the INTCXROM slot identifies a 16-bit address range assigned spe- SL0TC3R0M, and INTC8R0M soft switches. Gen- cifical y tothat slot. This range is normally used to erally, programs will do this because they need to command a peripheral to do things like gate data to access motherboard firmware routines in the the data bus or disable one of its functions. A card $C100— $CFFF range without interference fnjm design may require only one programmed com- peripheral card ROM. The monitor does this in a mand, such as a speech synthesis board which says a number of situations. The idea is to disable slot word when you store a value to itsonly address. This ROM, call the motherboard subroutine, then reena- type of card can use the DEVICE SELECT' to ble slot ROM after subroutine execution. Another trigger its action and it requires noon-board address decoding circuitry. Peripheral slot RAM cards usu- reason to disable I/O SELECT' and I/O STROBE' ally have a number of different configurations. would be to enable a peripheral card to steal DEVICE SELECT' enables reconfiguation of the $C100— $CFFF addressing via the INHIBir line. card, and the new configuration is determined by The remaining four peripheral signals are DMA the low order address bits and R/W. A card can IN, DMA OUT, INTERRUPT IN, and INTER- distinguish between 32 possible commands in the RUPT OUT. These are the DMA and interrupt DEVICE SELECT' range by decoding the states of priority chain connections described ingreatdetail AO, Al, A2. A3. andR/W. in Chapter 4, They are there to keep two or more The I/O SELECT' input to each peripheral slot cards from trying to simultaneously perform sim- identifies a 256-byte addressing range uniquely ilar functions. Only one card can perform DMA or assigned to that slot. This address range is normally interrupt the MPU at one time. The priority chains used by a 256-byte program in ROM or PROM. It can be used to keep order by giving high priority to has to be taken u p by a 256-byte program if the card lower numbered slots. is to be capable of response to BASIC "PR#" and A peripheral slot priority chain which does not "IN#" commands. What these commands do is cause exist but is very badly needed is an INHIBIT' prior- program flow to vector to the first address of the I/O ity chain. Apple realized this when they designed SELECT' range, so there must be a program stored the old 12K firmware card for the Apple II. Their there if PR# and IN# are going to work.* solution was to use the DMA priority chain to prior- The I/O STROBE' signal identifies $C800- itize the INHIBIT' based firmware card so that you $CFFF addressing for all seven peripheral slots can install two or more firmware cards in adjacent which share this range on an equal basis. The idea is slots. If two or more firmware cards are enabled at to store a big I/O handling program on a 2K ROM or the same time, only the highest priority card will PROM on a peripheral card and then give that card attempt to respond to its addressing range. This use sole access to $C800— $CFFF when it is active for of the DMA priority chain illustrates that the two input or output. As described in the next section, the priority chains are assigned to the DMA and inter- peripheral cards utilizing this "I/O STROBE' rupt functions by convention only. The hardware ROM" must deactivate response to the I/O reality is that you can use the DMA and interrupt STROBE' when $CFFF is detected on the data bus priority chains between slots. for any sort of serial communication during PHASE 0. This protocol prevents two ROMs from simultaneously trying to control the data bus There is no need for DMA IN or INTERRUPT IN when I/O STROBE' goes low. The I/O STROBE' signals at Slot 1 because Slot 1 is the highest priority ROM capability makes possible such peripherals as slot. Similarly, there is no need for DMA OUT or smart printers, smart 80-column cards, and smart INTERRUPT OUT signals at Slot 7. As a result, pins 27 and 28 of Slot 1 and pin 24 of Slot 7 are not ♦PR#0.IN#0,PR#3, and IN#3areinterpreted as special cases by connected, not assigned, and available for connec- Apple lie firmware. PR#0 and IN#0 cause program flow to tion to signals if Apple ever decides to do so. Pin 23 of vector to motherboard video output and keyboard input routines Slot 7 is connected via the X7 jumper to GR+2from rather than to a nonexistent program in nonexistent Slot 0, and . if pin 2 of the lOU. If your S!ot 7 peripheral requires a RAM card is installed in the auxiliary slot. PEl#3 and 1N#3 identification of GRAPHICS time, its installation cause program flow to vector tomotherboard 80-columii routines rather than Slot 3 firmware routines. procedure probably includes soldering of the X7 jumper. i^^tif m ,(W Input/Output in the Apple lie 7-21 Recall from Chapter 5 that INTC8R0M inhibits I/O STROBE' Protocol I/O STROBE' and activates motherboard ROM The I/O STROBE' signal at pin 20 of the pe- response to $C800— $CFFF addressing, that ripheral slots is the ROM enabling signal for any is cur- INTC8R0M is set by access to $C3XX when SLOT- peripheral card on which $C800— $CFFF control C3R0M is reset, and that INTC8R0M is reset by rently active. There are no motherboard access to $CFFF. In other words, the Apple He signals to tell the various slots when they may or 80-column motherboard firmware, in conjunction may not respond to the I/O STROBE', so Apple with SL0TC3R0M and INTC8R0M, fully emulates decided on the following protocol which cards a Slot 3 peripheral card that responds to I/O responding to I/O STROBE' must follow: SELECT' and I/O STROBE', with one subtle dif- 1. When pin 1 (I/O SELECT') goes low, a pe- ference. The difference is that motherboard firm- ripheral card may begin to actively respond to ware has hardware priority over the slots in response the I/O STROBE' at pin 20. to $C800-$CFFF. When INTC8R0M is set. moth- 2. When $CFFF is on the address bus during erboard firmware doesn't have to make an access to PHASE 0, all peripheral cards must stop $CFFF to disable peripheral card response to I/O responding to the I/O STROBE'. STROBE' because I/O STROBE' is inhibited by INTC8R0M. An example should clarify how the I/O STROBE' protocol works. Assume that Slot 1 and Slot 2 have The I/O STROBE' ROM capability should not be confused with the capability to steal addresses peripheral cards installed and that both have a $C800— $CFFF ROM on board. A PR#1 is executed $0100— $FFFF from motherboard ROM via the from BASIC which results in 6502 program flow INHIBIT' line. I/O STROBE' gives a peripheral card access to 2048 bytes of addressing when vectoring to address $C100 for all character output. INTCXROM and INTC8R0Mare reset. By pulling The card at Slot 1 responds to $C1XX addresses by placing a program on the data bus, and by activa- INHIBIT' low, any peripheral card can disable all motherboard memory from response to $0000— ting response to the I/O STROBE'. Suppose that the program driven out at address $C100 begins with: $BFFF and $C100-$FFFF. C100: BIT $CFFF THE APPLE t/O SYSTEM: KSW AND CSW C103: JMP $C800 The peripheral slot capabilities are determined by the signals connected to them, butour perception On the last cycle of execution of the first instruction, of how they work is very much colored by the opera- response to the I/O STROBE' is deactivated on all tingsystems that normally control them. The prece- peripheral cards including Slot 1, However, on the dents for I/O control in the Apple were established first cycle of execution of the second instruction, by the old Monitor ROM, the 2K ROM which con- $C1XX is back on the address bus and I/O STROBE' tained $F800— $FFFF firmware in the original response is again activated at Slot 1. It is now safe to Apple II. The main precedent is that memory loca- begin execution of programs stored in the $C800— tions $36 and $37 always contain the address of the SCPFF ROM at Slot 1. The ROM at Slot 2 will not Apple's primary output routine, and locations $38 interfere with Slot 1 access to $G800-$CFFF, and $39 always contain the address of the Apple's because it is designe'd to ignore the I/O STROBE' primary input routine. $36 and $37 are referred to ifter an access to $CFFF. in the monitor listing as CSW (Character output It is possible for a peripheral card to store its switch), and $38 and $39 are referred to as KSW $CnXX program and its $C800^$CFFF program (Keyboard input S Witch). )n a single 2K ROM. This is accomplished by ena- bling the output of the ROM to the data bus when Apple Monitor I/O t/O SELECT' (pin 1) goes low, or when I/O The Apple Il/IIe monitor has evolved over the 5TR0BE' response is activated and I/O STROBE' years just as the original Apple II evolved into the pin 20) goes low. If the card is located at Slot 1, the Apple lie, but a very large portion of the Apple lie i56 bytes at $C1XX will be identical to the 256 bytes monitor is identical to the original monitor that was It $C9XX. The 256 bytes at $C1XX can be accessed written by a computer hobbyist in his spare time tt any time. The 2048 bytes at $C800— $CFrF can back in the 70s. In particular, the same system is »e accessed only when I/O STROBE' response is normally in effect where every keyboard input is ■ctivated (after a $C1XX access). followed immediately by video output, and the input 7-22 Understanding the Apple He If, at power up, a disk controller is located, the and output routines are determined by KSW and program beginning at $CnOO ($C600 if Slot 6)on the CSW. lb see how this system works, let's examine controller is executed. This is the bootstrap pro- what happens at power up, initially assuming that gram that begins the DOS loading procedure. After there is no disk controller installed. DOS 3.3 is booted, CSW and KSW are set to The way the Apple presents itself to us is this: at addresses $9FBD and $9E81 {$B84B and $B84E ii power up, KSW is set to the address of a firmware ProDOS). Then all input/output passes through the routine (KE YIN) which waits for a keypress while DOS, which checks to see if it is disk related. For it displays a cursor; CSW is set to the address of a firmware routine (COUTl) which stores the ac- example, "CATALOG" is not a valid BASIC com- cumulator inTEXT memory while keeping track of mand, but it can be executed from BASIC whilethe DOS is connected, because it is a valid DOS com- the next screen memory address. Then, after search- mand. While you are entering BASIC code from the ing for a disk controller and not finding it, the keyboard with DOS connected, entries are checked Applesoft BASIC interpreter is entered. This pro- for DOS validity before control is passed to the gram, as do Integer BASIC, the system monitor, and many others, talks to humans through the BASIC interpreter for command processing, If a GETLN (GET LiNe) routine. BASIC program is actually running, the DOS does GETLN gets a series of characters from the little processing of input or output data except to primary input device which it finds by doing a check output data for a leading "CONTROL-D" JUMP INDIRECT to KSWL ($38). After it gets character. The "CONTROL-D" is a flag which tells each character, it stores it in an Input Buffer the DOS that a disk related command follows. (memory locations $200— $2rF), and sends it to the Entering PR#2 while the DOS is connected does primary output device by doing a JUMP INDI- not make Slot 2 the primary output slot. CSW and RECT to CSWL ($36). GETLN continues to input KSWwill still contain $9EBD and $9E8LThe DOS and output characters until it receives a carriage intercepts the PR#2 and does its own output setting return code from the input device. The program routine. DOS maintains its own I/O links— we will which called GETLN is then able to examine the call them DOSKSW and DOSCSW, DOSCSW is "line" of data in the input buffer and take action $AA53,$AA54 ($BE30/$BE31 if ProDOS), and based on its contents. The GETLN routine is largely DOSKSW is $AA55/$AA56 ($BE32/$BE33 if Pro- responsible for our impression of how the Apple DOS). PR#2 with DOS 3.3 connected results in talks to us. $AA53 and $AA54 being set to $00 and $C2. Slot 2 becomes the secondary output behind the DOS. If a Linking I/O to Other Devices PR#2 is performed from a running program, Slot 2 CSW and KSW are the I/O links. You can link the will probably actually become the primary input driving program for any device to the Apple and and output device, or it may not become connected at make it the primary input or output device. This is all, depending on its $C2XX firmware. If the$C2XX because most programs perform input or output by firmware automatically sets both CSW and KSW to jumping to the address contained in KSW or CSW, some value, then the DOS will be disconnected and As an example, you can connect a serial output Slot 2 will be connected as primary input and out- device to one of the annunciator ports and place a put. If the $C2XX firmware leaves the DOS con- control program in RAM. You then make this device nected atKSW, the first time an input is performed, the Apple's primary output by placing the entry the DOS will disconnect Slot 2 and reset CSW to address of your control program at CSW, If your $9EBD. The way to do a PR#2 from a running program is typical, after it outputs each character to BASIC program and leave the DOS connected is to your device, it jumps to the COUTl routine so the character is also output to the screen. do a PRINT : PRINT CHR$(4); "PR#2". The CHR$(4), CONTROL-D, flags the DOS that a disk Any peripheral slot can be assigned as the Apple's related command is following. The DOS type PR#2 primary input or output device by doing a "PR#n" or is performed, making Slot 2 the secondary output "IN#n" from BASIC, or an "n CONTROL- P" or "n behind the DOS.'* CONTROL-K" from the monitor. When a PR#1 is *A subtle difference between DOS 3.3 and ProDOS processinjis performed, $00 and $C1 are stored at locations $36 that DOS 3.3 identifies disk related commands from a carriage and $37. This means that if you do a PR#1, the card return output followed by "CONTROL-D", while ProDOS identi- in Slot 1 had better respond to $C100 with a pro- fies disk related commands from a BASIC PRINT statement in gram, because the 6502 is going to be executing at which "CONTROL-D" is the first character output. PRIhfT ; that address real soon. PRINT3.3 and DOS CHR$(4)r "PR#2" should satisfy the requirements of both ProDOS. Input/Output in the Apple He 7-23 Similar steps must be taken in assembly language since the 80-column capability should be automatic programs. If you change CSW to $9000, then the and not preclude the use of any I/O device. I don't first time a character input is called for, the DOS think you should have to enter PR#3 to get an 80- will change CSW baclt to $9EBD. You can do one of coiumn display, and I don't think you should lose threethings to get around this. You can change CSW your 80-column display when you press RESET or to $9000 and change KSW to $FD1B, disconnecting enable an I/O device via PR#n. For that matter, I the DOS entirely and connecting the keyboard as don't think you should have to install an auxiliary primary input. You can modify DOSCSW (AA53/4) card to achieve an 80-column display capability. to $9000, leaving the DOS connected. You can also The second category of cards is like the first store $9000 at CSW and do a "JSR $3EA". This is a except that the user must load the driving software DOS routine which takes the value you stored at from disk or other medium. This driving software CSW or KSW and transfers it to DOSCSW or DOSKSW, then restores CSW and KSW to $9EBD will typically bury itself above "HIMEM" and link itself to the Apple via CSW and KSW or DOSCSW and $9E81. $3EA is easy to remember if you and DOSKSW. This is a definite step down in con- remember "3 EACH".* venience from smart cards with firmware at $CnXX Peripheral Cards and Primary i/O Devices and possibly $C800— $CFFF. The program at $CnXX goes a little beyond offering the convenience The various peripheral cards can be divided into of PR#n and IN#n commands. Commercial pro- three categories: those with onboard firmware at grams such as word processors, assemblers, and $CnXX, those capable of being the Apple's primary data base managers allow records to be output to input or output device which have no $CnXX firm- any slot, if the slot has a $CnXX driver. These pro- ware, and those which would normally not be the grams usually make no provision for linking output Apple's primary input or output device. The first to a RAM address. category includes such cards as 80-column cards, The third category of cards is not normally linked smart printer interfaces, remote terminal inter- to the Apple via KSW and CSW. A 16K RAM card is faces, and the disk controller. The presence of not a conventional I/O device but simple memory onboard firmware with response to the simple PR#n expansion. A 128K card, however, may come with and IN#n commands should be an important factor an associated disk emulator program which does get in an Apple owner's choice among similar commer- linked. The DMA based manual controller shown in cial products. Figure 4.7 is a device which would not be thought of Peripheral cards with onboard firmware at in connection with the links. A secondary MPU card SCnXX generally will not work in Slot 3 if a RAM would not be linked. A speech synthesis card might card is installed in the auxiliary slot. This is because be linked, but it would just as often be driven by PR#3 is interpreted by Apple lie firmware as a special purpose subroutines in a larger program. command to activate the 80-column firmware if an auxiliary RAM card is present. The basic conflict is Understanding which of the three categories the that the 80-eolumn firmware is addressed at $C3XX cards in a given Apple fall into is a big step in understanding what is going on in that Apple. The and $C800-$CFFF, the Slot 3 I/O SELECT' and concept of peripheral slots integrated with the bus I/O STROBE' ranges. When the 80-column firm- structure of the motherboard is so powerful that the ware isactive, SL0TC3R0M is reset and Slot 3 I/O SELECT' is consequently inhibited. Cards which do "spirit" of the Applemay be under the control of any not respond to I/O SELECT' have no conflict with card or associated control program. When the con- trol breaks down and things do not function as they the 80-column firmware, and they can be used in should, the owner has only his own intellect to fall Slot 3 without restriction. back on to sort things out. Know your peripheral The 80-column firmware, in conjunction with SL0TC3R0M and INTC8R0M, emulates a Slot 3 cards; know your motherboard; know your opera- ting systems; know your Apple. peripheral card that responds to I/O SELECT' and I/O STROBE'. Tb me, this represents a weakness I/O TIMING •There is no equivalent to a "JSR $3EA" in ProDOS, but the I/O timing is the timing of the address decoded equivalents to DOSCSW and DOSKSW do exist. The ProDOS signals. All motherboard I/O and most peripheral I/O links are VECTOUT($BE30/|BE31) and VECTIN($BE32/ slot I/O is controlled by signals decoded in the '■routi SBE33), nes and these locations must be mod if ied d irectly to lin k I/O to ProD OS. MMU, peripheral address decoding circuitry, or 7-24 Understanding the Apple lie read access to $C090. This switches the direc- lOU. Access to a DEVICE SELECT' address exer- tion ofperipheral slot data bus driver so that the cises much of the address decoding chain, so that is data bus receives signal information from the the example chosen for analysis. peripheral data bus. The peripheral card in Slot Figure 7.7 shows read and write timing for access 1 can now place data on the peripheral data bus to $C090. The read and write are identical except for data bus management. Data bus management in a in response to its DEVICE SELECT' input. If write to $C090 is identical to that of RAM in a write the Slot 1 card does not take control, the floating cycle, because in all non DM A writecycles, the data peripheral data bus stores motherboard video bus and peripheral data bus are receivers of 6502 data which is valid on the peripheral data bus write data. I/O read cycle data bus management is when MD IN/OUT' rises. The video data is different from that of a RAM read cycle, because transmitted to the data bus for reading by the MD IN/OUr rises during PHASE 0 when I/O MPU. addresses are read.* MD IN/OUT' switches the 6. MD IN/OUT' falls at PHASE 0 falling plus direction of the peripheral data bus driver to allow MMU propagation delay (about 50 nsec) during the MPU to receive data coming from I/O devices. read access to $C090. This switches the direc- A description of important events of Figure 7.7 tion ofthe peripheral slot data bus driver so that follows here. Please refer also to Figure 7.1 for the peripheral data bus receives signal infor- clarification. mation from the data bus. The Slot 1 card must now release control of the peripheral databusor 1. C ASEN' and CXXX go high after an address in it will compete with the peripheral data bus the CXXX range becomes valid on the address bus. Even though these signals are not gated by driver. In most, and perhaps all, Apple lie's, PHASE 0 in the MMU, the logic circuits which MD IN/OUT' falls after 6502 PHASE 2 falls. they enable are gated by PHASE 0 (or PHASE The DEVICE SELECT' and I/O SELECT' sig- 1 low). CASEN' high disables communication nals are commonly used by peripheral cards to gate with motherboard RAM during PHASE 0, and data to the data bus during read access, Their tim- CXXX high enables I/O signals to be activated ing for this function is less than perfect, as Figure during PHASE 0. 7.7 shows, but they still work. The problem is that 2. COXX' falls after PHASE 0 rises and rises after DEVICE SELECT' and I/O SELECT' {same as PHASE 0 falls during access to $COXX. This COXX' in Figure 7.7) come too early. They fall enables further decoding in the lOU and the 4 to before MD IN/OUT' rises, and they rise before 6502 16 decoder at CIO. I/O SELECT' signal timing PHASE 2 falls. As a result, peripheral cards are is identical to that of COXX'. likely to compete with the peripheral slot driver for 3. C09X' (Slot 1 DEVICE SELECT') falls after control of the peripheral data bus for a short period COXX' falls and rises after PHASE 0 falls dur- at the beginning of DEVICE SELECT' or I/O ing access to $C09X. Timing of C04X', C06X', SELECT'. Also, when peripheral cards often will not hold C07X', and the other DEVICE SELECT' sig- read data valid 6502 PHASE 2 falls. nals isidentical to that of C09X', 4. The peripheral data bus driver is isolated from Early DEVICE SELECT' and I/O SELECT' timing only poses a problem when relatively fast both the data bus and peripheral data bus dur- devices (such as the data register of the disk con- ing PHASE 1 of write cycles. Video data from troller) are responding to them with data. With motherboard RAM is therefore not available at slower devices like NMOS ROM, data response is the peripheral slots when PHASE 0 rises dur- delayed enough from gating inputs that data is ing write cycles. During PHASE 0 of write always valid at the right times. But even fast cycles, firstmotherboardRAMvideo data, then response peripheral cards work with the early 6502 write data is passed from the data bus to the peripheral data bus. DEVICE SELECT' and I/O SELECT'. The short duration bus fight occurs at a time when critical 5. MD IN/OUT' rises at PHASE 0 rising plus data transfer is not taking place, and it seems to MMU propagation delay (about 60 nsec) during cause no damaging system noise. The early removal ♦Reading keyboard data is an exception. Bus management when of data at the trailing edge causes no problem reading keyboard data is identical to that of reading mother- because data bleeds off very slowly from the floating board ROM. In both instances, an MMUsimaHKBD', ROMENX' peripheral data bus. In other words, Apple gets or R0MEN2') drops !ow during PHASE 0 to gate data from a away with it, but peripheral card designers should ROM to the data bus. be aware of the early timing. 1!'S!»fT.'*.'a^ ■ Input/Output in the Apple He 7-25 6502 PHASE2 ~l PHASED CXXX (I/O ENABLE) COXX' (SAME AS I/O SELECT') C09X' (SLOT 1 DEVICE SELECT' CASEN' CAS' J Change direction of peripfiefal MD IN/OUT' data bus driver / >READ K „.^, _ Floating data bus VIDEO DATA Mpu V holds MPU data T VIDEO/PERIPHERAL DATA DATA 'BUS DATA^ — ( \ \ V \ \ \ \ VIDEO\ \ f f f f f t t ■PERIPHERAL ■WTA BUS MPU DATA X DATA > Video data stays valid unless peripheral card controls data bus K VIDEO/ PERIPH VW \ r K VIDEO MTA MRU 6502 WRITE DATA iUS DATA DATA > WRITE \ \ Floating bus holds \dataJI J VIDEO V MTA BUS 6502 WRITE DATA l?ffifr-^ 4 MPU data valid i 'i Figure 7.7 Timing Dlagfom: Read/Write Access to $C090. '^i "*fe 7-26 Understanding the Apple He C07X' signal appears to be connected to pin 6 of the Timing for the C06X' serial input enable signal is auxiliary slot for just this purpose. In this sense identical to that of DEVICE SELECT'read , and the same timing abnormality exists. When access C07X' is like a DEVICE SELECT' signal for the auxiliary slot. It can be used for this purpose as long is made to $C06X. C06X' falls before MD IN/OUT' as a program that resets the paddle timers does not rises, and the serial input multiplexor momentarily interfere with the auxiliary card bank selection competes with the peripheral driver for control of functions. D7 of the peripheral data bus. Also. C06X' rises Another scheme which has been used in auxiliary before PHASE 2 falls so the serial input multi- card designs is to include an alternate microproces- plexor isnot holding D7 valid when PHASE 2 falls. sor in addition to one or more 64K banks of RAM. Again, the slow bleed off of data from floating D7 results in correct data transfer to the MPU. This means that the auxiliary card is actually a Figure 7.7 shows that when a peripheral card separate microcomputer with its own RAM, copro- doe.s not respond to read acces.s in its DEVICE cessing with the motherboard 6502, and capable of communicating via data in auxiliary RAM accessi- SELECT' range by placing data on the data bus, the MPU will read the motherboard video data from ble by either microprocessor. All I/O in this copro- PHASE 1 video scanning. This occurs because first cessing arrangement is accomplished by the the floating data bus, then the floating peripheral motherboard MPU, including loading of programs data bus, then the floating data bus again store the from disk to auxiliary RAM where they can be exe- video data while MD IN/OUT' switches peripheral cuted by the alternate MPU, driver direction to, from, and to the data bus. In the The timing signal group consists of full connec- same way, motherboard video data is read by the tion to all outputs of the timing generator plus the MPU when access is made to any non-responding ENTMG' line, A diagnostic card in the auxiliary address in the $C020-,$CFFF range. slot can thus monitor all of the timing signals to determine whether or not they are operating cor- THE AUXILIARY SLOT rectly. The diagnostic card can also pull ENTMG' high to disable all outputs of the timing HAL and The auxiliary slot is of a different nature than the inject substitute signals to the motherboard (see peripheral slots. It is not connected to the address Figure 3,9). Furthermore, if an associated card in bus or f>5()2 control lines, has no enabling signals peripheral Slot 1 pulls CLKEN' high to disable like DEVICE SELECT', is not assigned to any 14M, the auxiliary card can inject an alternate 14M addresses in the Apple memory map. and has only a signal to the motherboard. very limited DMA capability. Instead of being a The video generation signal group consists of versatile I/Oorexpansionportin the Apple memory all of the address and chip enable inputs to the video map, the auxiliary slot is wired so that the installed card can be integrated into the operation of a func- ROM plus PICTURE', SYNC, CLRGATE' and ALTVID'.* A card in the auxiliary slot can thus tional area of the Apple lie. Figure 7.8 shows the monitor all of the video ROM inputs plus PIC- wiringconnectionstotheauxiliarycard with related signals grouped together. There are three major TURE', SYNC, and CLRGATE' to verify correct operation and isolate faults. It can also disable the signal groups, the RAM group, the timing group, and the video generation group. video ROM and, consequently, the PICTURE' sig- The RAM signal group consists of the multi- nal and then inject its own ALTVID' signal in reac- tion to the other video group signals and in place of plexed RAM address bus, the video data bus, the the PICTURE' signal. The ALTVID' signal is there- data bus, R/W, R/W'80, CASEN'. and EN80'. As fore an alternate picture signal, injected from the shown in Chapter 5, these connections (along with some of the timing inputs) support a 64K RAM card, auxiliary card to the motherboard when ENVID' is pulled high. It could also be used to bring various scanned for video output during PHASE 1, and areas of the screen to the white level while ENVID accessible by the MPU during PHASE 0. This is the is low, regardless of the current state of the scanned function we normally think of in connection with the display map. auxiliary slot, simply because it is the one commonly supported by commercially available cards. The Apple lie design supports full access to 64K of 'Another way of sUting this is that the video generation signal RAM in the auxiliary slot, but it is possible to place grouption consists of the lOU signal outputs related to video genera- multiple 64K banks on an auxiliary card and switch plus PICTURE', ENVID', and the video data bus. Note that between them by decoding the $C07X range. The the tion videogroupdata bus as as well canthebe RAM considered group.as part of the video genera- Input/Output in the Apple He 7-27 40 4 ^ (4.2) 21 16 17 20 39 45 4^ MD7 MD6 M05 MD4 MD3 MD2 MD1 MDO RAO VIDO 10 VID1 49. 51 RA1 42 VID2 RA2 41 48 RA3 If VI D3 38 13 RA4 VI04 22 46 RA5 RAM GROUP VID5 19 RA6 VID6 15 14 5.2) RA7 VID7 R/W ^Ji. 37 4.2) (5.13b) R/W80 26 35 52 CASEN' COLOR REF SYNC 0 (8.; EN80' VID7M SEGC WNDW 23 127 THEN 15". Actually, the greater. This is tolerable with a paddle set but less delay in this last cure is probably long enough to ensure that Timer 1 is reset by the time -16288 is tolerable with a 1-inch joystick which is already actually examined, but you will be sure if you use it. very sensitive to the touch. The interference between timers is more pro- Assembly language programmers should not feel nounced when calling PREAD from assembly lan- tied to PREAD, PREAD is handy and often ade- guage programs. This is because machine language quate, but it's not the last word in reading paddles. is so fast that hunrireris of instructions can be exe- Figure 7.9 is a program which reads Paddle 0 and cuted after a PREAD routine, and some of the Paddle 1 simultaneously, an obvious capability timers may still bo set. It is also possible for a since all timers are triggered simultaneously. This PREAD to a timer to interfere with a subsequent PREAD to the same timer. Consider the following paired paddle poller polls the pair of paddles pre- cisely in22-cycle loops, and therefore returns values program sequence: equal to one half of what they would have been if LDX #0 JSR PREAD read by PREAD. The Paddle 0 value is returned in JSR PREAD the Y-register and the Paddle 1 value is returned in STY SAVEPt) the X-register. The values can each be shifted left You may have wanted to cause a paddle variable one bit for compatibility with PREAD if this is delay with this sequence. Now if Paddle 0 is fully desirable. The advantageof reading the two paddles clockwise, the first PREAD is done normally, but together is that paddle reading time is cut in half. the second one returns a low value instead of 255. The full mechanical range of each paddle is used This is because the first PREAD is exited as soon as and the number returned is 0 to approximately 160. 256 polling loops have been performed. Timer 0 is It can be argued that no resolution is lostsince 1/256 still set though, and it is therefore already set when resolution exceeds the practical resolution of a, % the second PREAD isentered. The resultis a return inch diameter carbon potentiometer and possibly value in the Y-register of 70 or so instead of the the stability of a 558 timer. In other words, it's hard expected 255. to find a point on the pot where the PREAD routine Misreading a timer due to a previous call to returns a single value that does not jump back and PREAD can be avoided by preceding all calls to forth between readings. It is also very hard to adjust PREAD with a check like this: the paddle so as to increase or decrease the returned LDX PDLNUH value by one. Resolution of 1/160 is easily good enough for this hardware. NOTRDY LDA PDL0,X BMI NOTRDY A final recommendation for speeding paddle JSR PREAD reading is to integrate the timer polling with other program execution. The time delay problem exists Input/Output in the Apple He 7^31 SOURCE FILE: SIMULREAD ^ ****************************************************** 4 * SIMULTANEOUS READ OF PADDLE -0 AND PADDLE-1 2 * 0000 6 3** BY JIM SATHER 0000 0000 8 5 * * 1/24/83 0000 0000 7 * Ij^ ****************************************************** 109 * » 0000 12 ** PADDLE-0 14 DIVIDED BY 2 IN Y-REG 0000 13 ** PAODLE-i 15 DIVIDED BY 2 IN X-REG 0000 17 16 ** SIMULTANEOUS READ PROGRAM LOOP IS 22 CLOCKPULSES. 19 ** MONITOR PREAD ROUTINE PROGRAM LOOP IS 11 CLOCKPULSES 18 0000 21 * C064 22 * 23 0 PDL0 EQU 3C064 006 5 PDLl EQU $C065 C070 24 PTRIG EQO 0000 25 * $C070 0000 26 * ivm 1 T r n km Lj **'-»-t^ 131^ SIMULREAD. OBJ0 »1 «£iAi OQjb(»i riD T L riuE. SMrtnc n it 1F00 ORG 1F00 :AD 70 C0 28 27 DOIT LDA PTRIG $1F00 >A0 1F03 :A2 00 29 LDX 1F05 00 30 LDY #0 1F07 :48 31 PHA GI GIVE SOME SPACE FOR COUNT = 0 1F08 ;e8 32 PLA #0 1F09 :24 00 33 GOTPDLl BIT 1F0B :AD 64 C0 35 CHKPDL0 BPL 34 LDA PDL0 50 1F0E 10 0D GOTPDL0 1F10 :EA 36 NOP IFII :C8 37 INY 1F12 :AD 65 C0 38 LDA PDLl 1F15 t30 02 40 39 BMI BPL NOGOTS 1F17 :10 P0 GOTPDLl 1F19 :E8 41 NOGOTS INX IFIA .4C 0B IF 43 42 JMP CHKPDL0 IFID * IFID * iFlD 24 00 45 GOTPDL0 BIT 44 IFIF AD 65 F5 C0 47 46 IF22 30 LDA BMI PDLl 1P24 60 NOGOTS 48 $0 RTS **• SUCCESSFUL ASSEMBLY: NO ERRORS j Figure 7.9 Assembler Listing: A Paddle Reod Program. " ■'St*?!' 742 Understanding the Apple He as lone as normal program flow must wait thou- can check the previously triggered timer to see if it sands of microseconds for a timer to reset. When the has reset yet and increment a counter if it hasnl Daddies must be read often and speed is important, You wind up reading the timer with a resolution of it may be necessary to arrange routines so that they about 1/33 which really issufficientfor many tasks, can check the timer states occasionally, only inter- Of course, this would be a complicated program, but rupting program flow momentarily. For example, the results would be rewarding. Complicated pro- suppose that you are computing HIRES plot coordi- grams are within the capabilities of any reader of nates ina 100-cycle loop. At the end of each loop, you this book who has the time and the urge. fet« Input/Output in the Apple He 7-33 HARDWARE APPLICATION EXTENDING THE GAME I/O SOCKET Have you ever seen an Apple with two joysticks Let's look at the simpler circuit first, pictured in plugged in? Why not? It's a capability of the Apple. the photos of Figure 7. 10. Th is is a padd le set with an The answer is that when a standard joystick or pad- extension socket soldered on top of its 16-pin plug. dle set is plugged in to the game I/O socket, the pins Pins () and 10 are removed from the upper socket for one pushbutton input, two paddle inputs, four because these are the PDL 0 and PDL 1 inputs annunciator outputs, and the C040 STROBE' which are being used by the paddle set. PBO and beconne inaccessible there. It would do you no good PB 1 are fed to the extension socket even though they to plug another joystick into the extension jack in the are used by the paddle sets. Switch inputs can be back, because all the standard joysticks support paralleled, so one of several switches can operate a only Paddle 0 and Paddle 1. Your two joysticks given pushbutton input. Potentiometers, however, would just interfere with each other, cannot be connected simultaneously to a timer Now I don't mean to imply that the extension jack input. They would interfere with each other. gives no added capabilities. To the contrary, when a Thebenefitof the extension socket is that with the joystick or paddle set is installed in the extension extended paddle set installed in the game I/O jack, all of the game I/O signal lines are still acces- socket, the other signal lines are still accessible sible at the game I/O socket. Additionally, even there. But the modification must be performed when a plug is installed in the extension jack, it is carefully to ensure mechanical strength. The first fairly easy to attach a spring loaded clip to any of the step is to buy a high quality Ifi-pin DIP socket. You signal 1 ines on the back of the extension jack . But the will also need to buy a Ifi-pin plug and cover like the fact remains, if you want to switch between paddle one used on Apple paddle sets designed for the game and joystick or use two joysticks connected simul- I/O socket. We assume that the i>lug to be modified taneously tothe four Appie timers, you need to use on the paddle set or joystick is so thoroughly glued some sort of extension device which supports the and sealed that .\'ou cannot hope to solder a socket to capability, it. Here is the procedure to mount the extension Several game I/O extenders are commercially socket on your paddle set: available for the Apple. Th is application note shows two extension circuits you can build yourself. One is 1. Se[)aratc the cover from the plug on j'our paddle simple, allowing you to plug a joystick or paddle set set. If \'ou think ycsu can solder a socket to this mess, proceed to step 8. into the game I/Osocketand still havea 16-pin DIP socket available with the remaining I/O pins acces- 2. If you cannot salvage the old plug, remove the sible. The other is more complex, allowing you to two resistors from it (if they are there), and cut have two paddle sets and two joysticks simultane- the wires from it which lead to the jjaddles. ously connected with switched control betw^een 'A. Strip one inch of the outer insulation from the paddles or joysticks. This game I/O extender also wire bundle going to each pafldle. This exposes contains an extension socket for connection to other three insulated wires in each bundle. If Apple is devices. consistent, the green wire goes to +5V, the white ijlitiitiji VIJJJJJJ Figure 7.10 A Modified Game I/O Plug. 7^ Understanding the Apple lie 6. Figure 7. 11 shows the wiringof the plug. Install wire is the pushbutton wire, and tiie black wire the two resistors first (if they were there), mak- is the paddle wire. This should be verified with ing sure the leads do not extend very far beyond an ohmmeter. With the ohmmeter, find the two the solder posts. If you are certain that the pad- wires connected to the pot. The resistance across dle set will be used only in an Apple He and them will vary between 0 and 150,000 ohms as never in an Apple II, do not install the resistors. the paddle is turned. The wire left over is the If there are no resistors and you wish to use the pushbutton wire. Now find which wire is shorted paddle set in an Apple II, install 560 ohm resis- to the pushbutton wire when the pushbutton is tors as shown in Figure 7.11. Make certain the pressed. This is the 5 Volt wire, and the other wire is the paddle wire. resistors are not in the paddle body before doing 4. Some paddle sets have a fourth wire going from this (see step 4). the plug to the paddles. This wire is ground and 7. Connect the wires and solder. Use a low wattage iron and do not overheat the pins or the plastic should be connected to pin 8 of the plug. Pres- base will be damaged. Insert the plug into a ence of the ground wire idicates that pushbut- ton pull-down resistors are mounted in the spare socket while soldering to keep the pins paddles instead of the plug. The ground wire heating. if the plastic becomes soft from over- aligned can be identified because there will be 200 — 1000 ohms resistance between it and the push- 8. If necessary, sand down the corner of your button wire. socket so the plug cover will slip over it. Pull 5. Cut the paddle wires for each paddle back |4 pins 6 and 10 out of the socket or cut them off if inch. Leave the other four wires at their present the plastic is molded around the pins. length. Strip ii inch of insulation off the end of 9. Fit the socket over the paddle set plug and hold all six wires. this assembly lightly together in a soft jawed 5V WIRES BUTTON-0 WIRE BUTTON-1 WIRE PADDLE-0 WIRE PADDLE-1 WIRE TO TO PADDLE PADDLE 0 1 Figure 7.1 1 Wiring a Paddi© Set Plug. ,i^ Input/Output in the Apple lie 7^36 tsta /■'/;'• " ■ ■- ^^■^5^^ ■ ^.* • 4 Figure 7.12 This Game I/O Extender Can Support Two Sets of Paddles end Two Joysticks Simultaneously. vise. All wires should be dressed inside the pins A third switch is necessary if you wish to use the of the socket and the socket pins should be out- extender with an Apple 11 with the SH IFT key mod side of the plug pins. Solder the 14 pins of the installed.TheSHIFTkey mod works by connecting socket to the appropriate pins on the plug. the SHIFT key to PB2, but neither the SHIFT key mod nor a pulled down pushbutton will work if both 10. Check out the operation of your paddle set and are connected to FB2 at the same time. The game extension socket. I/O extender allows you to have both installed by 11. If you desire, fill the area between the plug and selecting between them via S3. The norma! SHIFT expansion socket with epoxy or a sealant like key mod istoconnectoneof theSHIFTkeystopin 4 RTV. This will give your assembly more me- of the game I/O socket. With the game I/O ex tender, chanical strength. Do not seal the assembly until you are certain it works correctly. the SHIFT key should be connected to pin 16 (nor- mally not connected) of the game I/O socket. Then 12. Cut the top off the plug cover so the topless plug switch S;^ can select between pin 16 and a paddle or cover is 5/16 inches high. Cut out a small notch joystick pushbutton for routing to the PB2 input. for the wires to pass through. Slip the cover over In the Apple He. the shift key mod is available via your assembly and glue it on with a small the X6 motherboard jumper. When this jumper is amount of epoxy cement. Remember that you made, a puDed down pushbutton cannot be con- may want to get back in there some day. nected toPB2 for reasons cited in the previous para- graph. Ifyou must have the SHIFT key mod in the Figures 7.12 and 7.14 are photos and a schematic Apple He. two alternatives are: leave S3 in the diagram of the more ambitious game I/O extender. SHIFT key mod position when the gameextender is This unit is meant to sit outside of the computer case, installed in an Apple He with X6 soldered, or con- connected to the game I/O socket via a 16-pin DIP nect a wire from the SHIFT' line to pin 16 of the jumper. It is basically six 16-pin sockets wired game I/O socket instead of soldering X6. together with some configuration switches. The The extender construction technique is to mount scheme is this: two of the sockets are meant for the six sockets on a general purpose IC board. Use paddle sets. One of the paddle sockets is connected the type with feed through solder holes so wires can normally but the other is connected so a standard be connected on both sides of the board. The board is paddle set will control Timers 2 and 3. Two of the mounted in a case with six holes through which the sockets are meant for joysticks. The joystick sockets sockets fit. A nibbling tool is good for cutting the are wired so all four timers are utilized by two joy- holes. The installation procedure is: install the sticks. Switch S2 places the joysticks in one of two sockets in the board; wire the board and switches as possible configurations as shown in Figure 7. 13. The shown in Figure 7. 14; mount the board and switches paddles and joysticks may be connected at the same in the case. The appearance of your extender will time. Switch Si enables either the joystick or the paddles. vary with your selection of switch styles and enclo- sure. Enjoy your extender. It's really pretty handy. 7-36 Understanding the Apple He ©0 El PADDLE B PADDLE A © 0 JOYSTICK CONFIGUAHATION I JOYSTICK CONFIGURATION 1 JOYSTICK A JOYSTICK B JOYSTICK A JOYSTICK B ® © 0 0 © 0 0^^ Figure 7.13 Game I/O Extender Configurations. INPUT EXTND PDLA PDLB JSTKO A JSTK B o 5V O— — O— 1 O O C040 -o- 5 o- GROUtJD 8 o- NC AN3 9 O- ^ AfJ2 12 O- 0 13 O AN1 AND 14 O — y7^ 15 O- PBO -O— PB1 2 o- -o- 53 PB2 SHIFTKEVMOD 3 O— SHIFT 16 O- PDLO 6 o- P0L1 PDL2 10 O- POLS 7 O- 11 O- SI 32 Figure 7.1 4 Schematic: A Game I/O Extender. Input/Output in the Apple lie 7-37 HARDWARE APPLICATION GAINING ACCESS TO THE ALTERNATE KEYBOARD SET The keyboard circuitry of the Apple He is typi- and cutting the XI jumper. Then AN2 will switch cally Apple. Man, this circuitry is neat, a versatile between keyboard layouts with the alternate layout design which makes the Apple He superior to other selected when AN2 is set ($G05D). You can then computers. Also typical of Apple, the keyboard ver- switch between layouts at anytime from a program, -16292/1. satility isnot advertised as a selling point, it is not or at the keyboard by accessing $C05C/D or documented for people who don't read schematics, and minor changes are made which make it difficult You can also make AN2 switch between keyboard for information disseminators like myself to devise sets with Revision B motherboards, but it is more clear, concise descriptions. Hey up there at Apple. involved because the keyboard ROM AlO input is We're not witless walking wallets down here. We connected to ENVID'. You can make AN2 control can appreciate the finer features of the Apple He. ENVID' by soldering the X3 jumper, but enabling Enough criticism. The Apple He does have a very the alternate keyboard layout will disable video versatile keyboard circuit which enables access to generation. I don't know what Apple was thinking of an alternate keyboard layout and easy redefinition when they tied ENVID' to the keyboard ROM, of the keyboard and numeric keypad layouts. Also, If you really want AN2 control of the keyboard the inclusion of Dvorak as an alternate keyboard layout on a Revision B motherboard, perform the following: layout might lead to similar action by other manu- facturers and eventually lead to acceptance of Dvorak as the English language standard keyboard 1. Cut the X2 jumper to isolate ENVID' from the keyboard ROM. layout. Conventional wisdom is that Dvorak doesn't 2. Solder a short wire between the back half of the have a chance because too many people have learned QWERTY, and normally available typing machines X2 jumper and the back half of the X3 jumper are all QWERTY. But suppose Dvorak becomes (don't solder the two halves of X3 together). The back half is the half situated toward the back of available as an alternate layout on virtually all typ- the motherboard. ing machines. Wouldn't some people convert to Dvorak, and wouldn't typing instruction courses A problem with using AN2 to switch between begin to teach Dvorak? If the seedling takes root, we keyboard layouts is that the alternate set will always all may be touch typing at a higher pitch in a gener be selected after a system reset. It is true that all the ation or two. annunciators are reset when RESET' drops low , but There are other reasons for accessing the alter- the firmware RE SET' handler proceeds to set AN2 nate keyboard set than learning to touch type in and AN3 (I don't know why). The result is that your Dvorak. Suppose you have a numeric keypad and keyboard will be set to Dvorak at power up and wish to assign special function ASCH to the various whenever RESET is pressed. This is probably keys so your application software is easier to oper- undesirable, but you can reverse the situation by ate. For example, i£ you use Applewriter a lot, you installing a keyboard EPROM identical to the nor- could assign the ASCH of the various Appleuriier mal keyboard ROM but with the top half swapped control keys to the alternate numeric keypad junc- with the bottom half. Then the QWERTY layout tion code. Normally your keypad would have will be selected by system resets. numeric ASCII, but selecting the alternate set I recommend installinga manual switch to select would make your keypad an Applewriter controWer. between keyboard layouts rather than depending on Of course, you would need to program a custom AN2. The reason is that you never know what some keyboard EPROM with your desired alternate key- program is going to do with AN2, and you might pad layout to gain this feature. find yourself in Dvorak when you want to be in Other uses for the alternate set are possible. The QWERTY. Other reasons are that a special key- question is, "how do you access the alternate set?" board EPROM is not required, and that this is the The answer is "there are several ways, none of which sort of function over which manual control is best. is particularly complex." Read on. The manual switch needs to bring pin 19 of the If you have a Revision A motherboard, you can keyboard ROM high or low (see Figure 7.4). Here is access the alternate set by soldering the X2 jumper one installation that will work. 7-38 Understanding the Apple He 1. Solder wires to the bases of pins 12, 19,and24on socket and one of the two terminals on the a 24-pin IC socket. second switch. 2. Solder the other ends of the wires to a single 5. Solder a short jumper between the terminal of the firstswitch that is connected to pin 12 of the pole, double throw switch such that pin 19 is connected to the common terminal, and pins 12 socket and the remainingunconnee ted terminal and 24 are connected to theother two terminals. of the second switch. 3. Remove the keyboard ROM and install the 6. Install the socket/switch assembly as above mounting the two switches near each other on socket/switch assembly in the vacated mother- board socket. the back of the Apple He. The 2732 EPROM 4. Install the keyboard ROM in the socket/switch with your four keyboard layouts is installed in assembly. the wired socket which, in turn, is installed in 5. Mount the switch in a convenient hole at the the keyboard ROM socket of the motherboard. back of the Apple He, The preceding paragraphs mentioned several 6. If Rev A, cut jumper XI to isolate pin 19 of the instances in which you might wish to program your keyboard ROM from ground. own keyboard EPROM. There are other reasons for 7. If Rev B, cut jumper X2 to isolate pin 19 of the doing this. One reason is to operate with a numeric keyboard ROM from ENVID'. keypad that wasn't originally designed for the Theswitch will now placeeither 5 volts or ground Apple He. This is done simply by reprogramming on pin 19 of the keyboard ROM. thus selecting that part of the keyboard ROM assigned to the between character sets. numeric keypad. Another reason isto makea minor Are two keyboard layouts enough for you? If you change in the standard layout to suit your prefer- need more, you can carry the above installation ence. For example, I use both a Kaypro and an procedure a step further to mechanize switching Apple He, and am annoyed by the fact that the between four sets on a 4K EPROM (2732). The 2732 arrow keys on the Apple are laid out "left, right, is compatible with the 2716. except that pin 21 is down, up," and the arrow keys on the Kaypro are All instead of VPP, Perform the following to adapt laid out "up, down, left, right." I don't care how they to 2732: lay out the arrows as long as they're the same so I can get used to them. The solution is to reprogram the 1. Wire a 24-pin IC socket as instructed in the keyboard ROM so that the Apple He keys are laid above installation procedure. out like the Kaypro keys. Then just pull off the key 2. Bend pin 21 of the wired socket out so it will not caps and reinstall them in the new order. make contact when the socket is inserted into T^ble 7.2 provides a useful guide for persons wish- the keyboard ROM socket on the motherboard. ing to program thei r own keyboard EPROM for any 3. Solder a wire between pin 21 of the socket and reason. EPROM addresses for any key can be com- the common terminal of a second single pole, puted from the Table 7.2 base address using the double throw switch. guide at the bottom of the table. Use of 2732 will 4. Solder a short jumper between the terminal of create a second table, identical to Tkble 7.2 except thefirstswitch that is connected topin24ofthe with base addresses increased by $800, chapter 8 Video Generation V^J^STTT—, ■ 1 The marriage of data processing: and video dis- video display. All of these functional areas are inter- play technology has been one of the most important connected ina scheme which allows Apple pro- developments in the advance of computers. Com- grams to control the video output. bined with the keyboard, the video display provides Figure 8.1 is a simplified diagram of the video a direct communication link between people and display control processes ofthe Apple He. As Figure computersthatmakestheold, expensive, physically 8.1 shows, the MPU controls the output of video in a large computers seem to be just machines. Imagine very indirect way. Under direction of the control- communication with your Apple using a teletype terminal with no video display. How would that ling program, the MPU sets the screen mode, com- putes a correct address in memory, and stores affect important applications like word processing, selected code at that memory address. In so doing, spread sheet accounting, data base management, the MPU is setting up a small area of the screen graphics display, and Donkey Kong? Without video, map. The extent of MPU involvement and, by the Apple wouldn't be worth owning. extension, programmer involvement in outputting Of course, the Apple does have a video display video consists entirely of setting up this screen map. capability, and a large portion of the motherboard The actual output of video is controlled by the video hardware is related to the generation of video. We scanner which scans memory and drives out the have seen in other chapters that many features of map, and by the video generator which processes the bus structure, timing, and RAM addressing in the map to produce the VIDEO signal. You can actu- Apple He are dictated by the fact that the dissim ilar the MPUwillbycontinue READY pulling to or DMA' low, tasks of stored program execution and video display thestopApple and ally output to the screen generation are performed simultaneously in this the map which was set up by the MPU before you computer. Additionally, the video scanner (inter- nal to the lOU) and video generator (partly inter- stopped Compare it. this indirect MPU involvement to a nal and partly external to the lOU) are functional printer output port where the MPU— under pro- areas that exist for the sole purpose of making up the gram control as always— actually stores coded data 8-2 Understanding the Apple lie MPU . (Chapter 4) 1VIMU IWAP MPU DATA IN ADDRESS MUX (Chapters) 1 lOU VIDEO +1 PHASE 0 ADDRESS 1 l/IDEO ADDRESS MRBOARD RAM SCANNER - MUX PHASE 1 (Chapters) (Chapters) ' DISPLAY [Chapters] ADDRESS IN RAM PAGE AUX > MAP 2 / \ HIRES RAM 80STORE GP (Chapters) SOFT ESWITCHES (Chapter 8) MAP TEXT DATA MIX HIRES OUT ALTC IIM VI D7 VI D6 ■ VID0-VID5 DUINT ^ VIQEO lOU EXT ^ VIDEO GEN c VIDEO ROM CONTROL GEN (Chapters) uinpn DISPLAY 1 SVNC-. CLRGATE' (Chapters) 80C GR+2 SEGB HO VID7 TIMING GEN AUX 14M.VID7M.LDPS' SLO T FRCTXT' [L OL' Figufe 8.1 Overall Video Generation. Video Generation 8^ er. The white televi- at a special address to output it to the print by the FCC, which allowed black and acces s to RAM by the video scann er is an sion broadcastingafter July 1, 1941. Updated NTSC sneaking standards for color television broadcasting were sleep - pxampie of DMA, which is like someone else inir with your spouse. RAM in the Appl e is very adopted by the FCC on December 17, 1953. The nromiscuous. It goes to bed with the video scann er American television must be designed to receive .-it goes to and process NTSC standard signals. every other night. Then on most off nights what When the original Apple II was built, the FCC bed with the MPU. The MPU has no idea unfaithful RAM is up to during PHASE 1, frowned on the idea of computers outputting radio the The video generator must take theoffsprmgof frequency signals to a televisio n because it is pos- scanner/RAM affair and interp ret it as text, LORE S sible for a tiny amount of the computer signal to be graphics, or HIRE S graph ics to produ ce a signa l radiated and cause interference with television which causes a television or monitor to produce the reception in the neighborhood. Please note that this computer display. This signal is referred to as the level of radiation leakage is not a health hazard and VIDE O signal , and it is one of the more compl ex is smaller than the man-made electromagnetic fields signals in the Apple. The purpose of this chapt er is in which we all live. To avoid conflict with FCC to discuss the nature of the VIDE O signal , how it is regulations, the Apple 11 was designed to output produced in the video gener ator, and opera tiona l composite video which will drive an NTSC standard features of the Apple He resulting from the way the composite video monitor. Later, the Apple lie was VIDEO signal is produced. Other chapters of the designed tooutput video which iscompatible, and in book contain detailed descriptions which are impor- most respects identical, to the video which is output tant inachieving a broad understanding of how the from the Apple II. tasks of video generation and program execution If you modulate a radio frequency signal with the are integrated in the Apple lie. These (Chap include de- Apple's VIDEO signal, that radio frequency signal Of scriptions ofoverall video generation ter 1). will drive an NTSC standard television receiver. video scanning withi n the conte xt of bus struc ture RF modul ator may tend to course, your thirty dollar video scann er (Chap ter 3). and ion and interf ere with neigh borho od (Chapter 2), the leak RF radiat RAM addressing (Chapter 5). The subject at hand is television reception. The television takes the radio the video generator, and we begin our discussion frequency signal and converts it back to the same with a description of the Apple He VIDEO signal. VIDEO signal that left the Apple's video outpu t in itscir cuitry , the televi sion is jack. From this point THE APPLE lie VIDEO OUTPUT SIGNAL identical to a composite video monitor. Figure 8 2 shows the characteristics of the Apple Let's watch a television show for a minute; how VIDEO signal. It is made up of three compo nents: about . . . Taxi"! That Louie is really something. The the PICTURE signal, SYNC , and the COLO R picture we see originates with a camera which out- The signa ls are added REFERENCE BURST. puts composite video, a signal composed of picture, together in such a way that a television can teH them synchronization, and color information. This signal apart The telev ision can separ ate the SYNC from is routed to a transmitter which modulates a radio se, durin g SYNC pulses , the VIDEO signal becau frequency signal with the composite video and with the VIDEO signa l is at a '°^er volta ge than at any frequency sig- R BURSl, audio from a microphone. Theto radio nal isdistributed nationwide local stations which other time. It also can detect the COLO where to look for it-ng ht behind transmit the signal to receivers in their areas, The horizose becau ntalit knows blanking gate "backvtnF porcO h of the ^isrnal television in your home is a receiver/processor the horizontal sync pulse on the which extracts the audio and composite video from EO signal There is a voltage point on the VID the radio frequency signal and processes it to form refe renc e. Volt ages above the the picture we see and the sound we hear. called the black tube electron bing tele- black reference cause the picture the tube with The previous paragraph could be descri bean^ to strike the interior face of vision inany number of countries or continents in to result. The the world which broadcast television signals based enough velocity for light emissionk reference only w!ien VID sign EOi?is al goes abov e the blac time t^paint, and ^^^^y^^^^^^^l^^e on similar principles. The exact details of various signals vary, however, among several standard sys- reference the rest of the time. The SYNC blanking pu Ises are tems used in various areas of the world. The Ameri- the can standards were formulated by the NTSC blacker than black, extending below where they are detected as sync not (National Television System Committee) and adopted s gnal to a point We thus have a pkture signal, by the television. 8^ Understanding the Apple He VERTICAL BLANKING PERIOD WHITE LEVEL i IV BLACK REFERENCE — ' BLACK LEVEL 36V finrwmF SYNC LEVEL OV SHORT LONG HORIZONTAL HORIZONTAL LINE LINE ) DOT i J BOTTOM I WHITE BLACK H6L HORIZONTAL BLANKING - y - — HBL HORIZONTAL BLANKING • MARGIN I -VERTICAL SYNC- MARGIN TOP H HUHIiUNIALSTNU HORIZONTAL STNC LA I SLACK ~* REFERENCE RIGHT L-l " MARGIN LEFT MARGIN HORIZONTAL SYNC COLOR REFERENCE _A_ BURST WHITE -^ BLACK SYNC HOR SVNC iii iilil BURST '^ Figure S2 The Apple lie VIDEO Signal. three signal levels, the white level, the black level, vertical sync pulse in the Apple lasts for four com- and the syne level. The Apple signal is immensely plete horizontal scans. As in normal television video, less complicated than normal television composite there are sharp serrations in the vertical sync pulse video in this regard. The level of the picture signal in so that horizontal sync can be detected, even in the composite video can be any voltage between the middle of the vertical sync pulse. black level and white level at any instant. This is the There are 262 horizontal sync pulses for every way television reproduces the remarkable variety of vertical syne pulse in the American Apple. The 4- lightingshades found in a normal television picture. cycle horizontal sync pulse occurs in the middle of Even black and white television is really black and HBL, the 25-cycle horizontal blanking gate. Dur- white and innumerable shades of gray. The Apple ing HBL, the VIDEO signal is held below the black video, when color information is not present, is truly reference level, creating the right and left black black and white. margins on the screen {see Figure 8.3). The picture The horizontal and vertical sync pulses both de- signal occurs between the horizontal blanking gates, scend below the black level. Any sharp negative naturally, creating the screen display between the edge in the sync level is interpreted by the television left and right margin. The vertical sync pulse occurs as horizontal sync. Any long duration negative pulse in the middle of VBL, the 4550-cycle (70 horizontal in the sync level is interpreted as vertical sync. The scans) vertical blanking gate. The VIDEO signal Video Generation d^ " — ""^ o \ a " tj ^ o ra o-;= ^oi. —5," 0) yi c; > a " s - t a5 2Ln ::> "D £ 1>- 1 0) c c o g S 1 I S3 B ''^,^^,isi 8-6 Understanding the Apple He not set up to cause interlacing. It causes a non-inter- is held below the black reference level during the laced vertical scan of 262 lines, 192 of which are entire VBL period, creating the lower and upper black margins on the screen. displayed. Assume the electron beam is at the top left corner of the screen, and that the Apple display window on COLOR SIGNALS your television is 10 inches across. The beam is mov- The COLOR REFERENCE BURST isa 14-cycle ing left to right as you look at the screen, at about 10 sample of the COLOR REFERENCE signal from inches per 40 microseconds or about 14,000 miles the .timing generator. Color television sets are de- per hour. Since we are at the top, the vertical sync signed tolook for a 3.58 MHz signal after the hori- pulse has just occurred and it is the second half of zontal sync pulse. From this short burst, the VBL. The beam scans across to the right side of the television is capable of reconstructing the whole screen, but we don't see light on the screen because VBL holds the VIDEO signal in the black. The COLOR REFERENCE signaUtdoes this by "phase horizontal sync pulse causes the beam to retrace locking" an oscillator to the COLOR BURST. By very rapidly to the left side (none of this slow poke this method, the COLOR REFERENCE is trans- mitted tothe television, but it is not present at the 14,000 mph stuff) so it can scan across left-to-right same time as picture information, so it does not again. This cycle continues as the beam moves across again and again and less speedily down the interfere with the picture. Since the COLOR BURST screen to the first displayed line, aboutan inch from occurs during HBL, it is not displayed on the screen. the top of the screen. The COLOR BURST does not occur if the TEXT In the la.st undisplayed line. VBL ends about an soft switch is set. When no COLOR BURST is inch from the right side, but HBL begins at the same present, the color generation in the television is time, so the screen is still blanked. After the beam inhibited, so elimination of the BURST prevents scans past the right edge, horizontal sync occurs, undesirable coloration of screen text. The COLOR causing retrace, and the beam begins the first dis- BURST is not inhibited during TEXT time in played line. When the beam gets aboutan inch from MIXED mode, so the four lines of text at the bottom the left side of the screen, H BL ends and the VIDEO of the screen in MIXED displays have coloration signal begins switching back and forth between the (green, violet, and white assuming SINGLE-RES black level and the white level, decreasing and display mode). increasing the energy in the electron beam to cause Picture information in an NTSC standard televi- bright spots and lines on the screen interspersed sion signal is divided into two components, the color with black spots and lines. component and the brightness component. The About an inch from the right side of the screen, chrominance signal contains the color information HBL forces the VIDEO signal into the black where of the picture, and the luminance signal contains it remains until the beam has scanned past the left the brightness information of the picture. The two margin of the next line. This cycle continues for 192 signals are transmitted simultaneously and pro- displayed horizontal scans. At the end of the display cessed together in the radio frequency and interme- period of the last displayed line, VBL and HBL diate frequency stages of a television set. Once the begin together, marking the start of the bottom television signal has been converted from radio fre- margin. The beam scans the rest of the way to the quency to composite video, the television separates bottom in the black, then the vertical sync pulse the chrominance signal from the luminance signal causes a rapid retrace to the top of the screen, where and processes them individually. we began our description of the continuous cycle of the electron beam. The chrominance signal is a highly complex com- bination oftwo 3.58 MHz signals 90 degrees out of In NTSC standard television scanning, a process known as interlacing takes place. In interlacing, phase with each other. In an amazing mathema.ti- alternate vertical scans are displaced vertically by cal/electronic manipulation, the chrominance sig- nal contains the color information of each spot on the half the distance between two horizontal scans. This screen while the luminance signal contains the means it takes two vertical scans to actually paint brightness information of each spot. Part of this the complete television picture, and it is a tricky way of increasing vertical resolution without increasing mathematical manipulation is that the chrominance flicker. In NTSC scanning, there are 262.5 horizon- and luminance signals are present together in over- tal scans in each vertical scan for a picture com- lapping frequencies, yet do not interfere with each posed effectively of 525 lines. The Apple SYNC is other. In television video processing, the chromi- nance signal is separated from the composite video, Video Generation 8-7 then red, blue, and green color signals are extracted Apple VIDEO signal with little distortion. An from the chrominance signal by comparing it to the exception is LORES or HIRES80 gray PICTURE COLOR REFERENCE. signals, which will be converted to sine waves by In Apple video, the PICTURE signal takes the monitors of less than 21 MHz frequency response. place of the luminance and chrominance signals of The features of Apple graphics are largely depen- normal broadcast NTSC composite video. The PIC- dent on the way the Apple passes color intelligence TURE signal is a simple binary signal that goes to the television. There is no need to store HIRES high or low in accordance with text or graphics color information in memory. Dot position deter- patterns produced from the screen map during dis- mines color. Think of the savings in memory over a play periods. system where the color information of dots is stored In television processing, the Apple VIDEO signal as separate intelligence, The flip side of this coin is: is recovered from the modulated carrier wave and is think of the elaborate programs required to produce present at the output of the "second detector." The colored displays dependent on dot position. higher frequency components will, however, look There are four classes of Apple video concerning different than they did at the videooutput jack of the color. First is black, the absence of luminance. Apple. This is because the square waves of the Second is white, the absence of color caused by pic- VIDEO signal are converted to their sine wave ture signals less than 3.58 MHz. This occurs when components that are within the bandwidth of the two adjacent HIRES40 dots or four adjacent television signal paths. In televisions with the nor- HIRES80 dots are turned on, increasing signal mal 4.1 MHz IF bandwidth, those square waves pulse width and decreasing frequency so there is no greater than about 1.37 MHz are converted to sine 3.58 MHz signal for the TV to interpret as chromi- waves of the square wave frequency. This includes nance. Additionally, white occurs in a "COLOR = the COLOR REFERENCE BURST and higher 15" LORES block, which is identical to seven adja- frequency PICTURE signals, such as those which cent HIRES40 dots in four adjacent horizontal produce color in the Apple's display. This modified scans. White also occurs in TEXT mode where there Apple video is present at the input to the luminance is no COLOR BURST. and chrominance amplifiers, as well as other sec- Third is gray, the absence of color caused by 7 tions ofthe television. MHz picture signals. This occurs in "COLOR = 5" The modified PICTURE signal(ahigh frequency and "COLOR - 10" LORES blocks and in HIRES80 sine wave, a low frequency square wave, or medium displays in which every other dot is turned on, frequency combination) is passed by the luminance LORES colors 5 and 10 are identical to each other in amplifier and ultimately controls the brightness of shade and intensity and are the same as white the display. If the modified picture signal is oscil- except less bright. White horizontal lines are caused lating at3.58 MHz, it will also be passed by the by long periods of white level VIDEO signal . Gray is chrominance amplifier to the synchronous demodu- caused by 7 MHz oscillation of the VIDEO signal lator where it is compared with the reconstructed between white level and black level. The alternating COLOR REFERNCE to produce red, green, and black level causes gray to be less bright than white. blue color signals. Thus, the Apple VIDEO signals Fourth is colored video. This video is 3.58 MHz which produce colored displays on the screen are whether it is HIRES or LORES. There are four such those with a 3.58 MHz PICTURE signal.* HIRES40 colors and twelve such LORES and Processing in a composite video monitor is similar HIRES80 colors. Four of the LORES/HIRES80 colors are identical to HIRES40 colors: green, violet, ' to that in the video sections of a television, but the high frequency square waves may or may not have orange, and blue. The remaining eight colors come been converted to sine waves by the time they reach in four tones: light and dark blue, light and dark ; thechrominance and luminance amplifier inputs. If magenta, light and dark blue-green, and light and ! they are not already sine waves, the high frequency dark brown. Of these eight colors, six can be pro- : square waves will be converted to sine waves in the duced in HIRES40 as interference between adja- ; luminance and chrominance amplifiers. In high cent bytes of graphics data with bit 7 set on one byte .frequency response monochrome monitors, there is and reset on the other. ( no chrominance amplifier. The video amplifiers of This explanation of Apple color is based on analy- Jthese monitors will pass the square waves of the sis of the hardware and timing of the video genera- • Someexceptions to this rule and further discussion on television tor. The details are a little involved, but tread thou I processing are cotitainecS in a technical note at the end of this in my footsteps, tenacious reader, and thy tootsies J chapter. will not freeze. f ■^li.-,... 8-8 Understanding the Apple lie DISPLAY MAP MEMORY Apple He TEXT mode characters. This is not true REPRESENTATIONS ALTCHRSET only lets you switch between the funky INVERSE/FLASHING representations of The way in which displayed objects are represen t- the original Apple II and the businesslike full ed in memory varies with the display mode. TEXT ASCII INVERSE representation. If you want an characters are represented by ASCII with some alternate character set, you can get it by replacing variations in the code for NORMAL, INVERSE, or the INVERSE patterns in the video ROM with your FLASHING characters. GRAPHICS patterns are desired set in a custom video EPROM. represented directly in memory with illuminated In TEXT mode, each 40-byte display line in RAM portions represented by ONE and blanked portions is scanned eight consecutive times. For example, if represen ted by ZERO. Details of these representa- $C1 (code for NORMAL "A") is stored at $400, $Cl is tions are illustrated in Figure 8.4. driven out of RAM during each of the first eight TEXT ASCII from the display map is interpreted horizontal television scans just before the beam gets in one of two ways, depending on the ALTCHRSET to the first displayed character position. Video gen- soft switch. With ALTCHRSET reset, $00-$3F eration circuitry interprets VA, VB, and VC from represent 64 INVERSE upper/special/numeric the video scanner to determine which of the eight characters, $40— $7F represent 64 FLASHING 7-dot patterns that make up "A" on the screen it is time to shift out. As a result, 40 bytes contain the upper/special/numeric characters, and $80— $FF represent a complete 128-character NORMAL display intelligence for eight horizontal scans. ASCII set. With ALTCHRSET set, $00-$7F repre- Memory scanning in LORES is identical to that of sent a complete 128-character INVERSE ASCII TEXT, with each 40-byte display area scanned set. and $80— ?FF represent a complete 128-charac- eight times consecutively. But, rather than ASCII ter NORMAL ASCII set. for a text character, actual dot patterns are stored to The ALTCHRSET variation affects only the represent LORES blocks. Each memory location in interpretation of INVERSE and FLASHING code, the display map contains two 4-dot patterns, the not the NORMAL code. When NORMAL or upper block pattern in bits 0 — 3 and the lower block FLASHING text is to be displayed, the controllinK pattern in bits 4—7. During the first four times a program must coordinate ALTCHRSET configura- 40-byte display area is scanned (as identified by tion with maskingof bits6 and 7 of stored character VC), the upper block pattern is processed by the code to achieve the desired display. A complete list video generator, and the lower block pattern is pro- of the TEXT character representations is given in cessed during the second four times a 40-byte dis- Tkble 8.4. play area is scanned. The name of the ALTCHRSET soft switch leads Video generator processing of a 4-dot LORES one to believe that it lets the user select some alter- pattern consists of shifting the pattern to the PIC- nate to the standard dot patterns which make up TURE signal at a 14 MHz rate (twice the speed of LORES TEXT TEXT HIRES ALTCHRSET ALTCHRSET GRAPHICS GRAPHICS 1 NORMAL ASCI Q f ■^ D5 03 ^ D7 D6 D4 02 D1 DO 06 05 D4 D3 02 D1 DO 07 D6 D5 D4 03 D2 D1 DO 1 D7 06 05 04 03 02 01 DO ' D7 ^ ^ UPPER CASE, SPECIALj AS Cll Q LOWER BLOCK UPPER BLOCK PATTERN flOTATED PATTERN ROTATED 7-DOT PATTERN SHIFTED AT NUMERIC CODE. AT 14 MHz AT 14 MHz 7MHz(HIRE540)OR14MHl DURING VC. DURING VC. (HIRESSO). 0 = INVERSE 1 = NORMAL 0 = NO DELAY (HIRES40} 0 0 = INVERSE 1 = DELAY (HIRES*)| 1 = FLASHING NOTES: [T] Characters displayed for CONTROL ASCII identical to uppercase Q] D7 has no effect in HlfiESao mode S Text code and LORES patterns are driven out o1 memory for eight consecutive horizontal scans HIRES patterns are driven out only for one horizontal scan Figure hA Display Map Data Formats. rf-' ^Fi ■eFwi Video Generation 8-9 HIRES40 and TEXT40 patterns). The signal alter- These scanner gated signals perform various func- nations resulting from this high speed shift are too tions inthe video generation task such as blanking fast to be displayed clearly on a color television, so the picture, gating the COLOR BURST, and serv- they are blurred into colored blocks. You can actu- ing as the sync portion of the VIDEO signal. ally see the LORES pattern alternations if you use a A second key concept in Apple lie video genera- high frequency response video monitor with the tion isthat of the video ROM, translating video data Apple instead of a television. from the display map in RAM to dot patterns which HIRES patterns are stored directly in bit 0—6 of are shifted out to become the PICTURE signal. display memory locations as 7-dot patterns. Pro- Every half cycle, when PHASE 0 rises or falls, new cessing ofthese patterns consists of shif ti ng them to video data is present at the address inputs of this the PICTURE signal, seven dot positions per micro- ROM. Depending on the display mode and the cur- second (HIRES40) or seven dot positions per '/g rent state of the video scanner, the video ROM trans- microsecond (HIRES80). The patterns are shifted lates the data on the video data bus (VIDO— 7) to out LSB first, sotheLSB represents the leftmost dot graphics or text patterns. Then the video patterns position on the screen. This is the reverse of the way are loaded and shifted out by the load/shift regis- you visualize the numerical representation of the ter. In SINGLE-RES modes, the patterns resulting stored pattern (numbers have the LSB on the right). from auxiliary card RAM data are ignored and the Bit 7 of stored HIRES patterns is the delay bit. If patterns resultingfrom motherboard RAMdataare this bit is set in HIRES40 processing, the entire loaded and shifted out: seven HIRES dot positions, 7-dot pattern is delayed by one 14M period (one one LORES block, or one TEXT character per fourth a COLOR REFERENCE period). This delay microsecond. In DOUBLE-RES modes, patterns results in a very slight shift right, and consequent resulting from both motherboard and auxiliary change in coloring, of the 7-dot pattern on the card RAM data are loaded and shifted out: 14 screen. Without the delay, HIRES40 patterns are HIRES dot positions, two LORES blocks, or two black, white, green, and violet. With the delay, TEXT characters per microsecond. HIRES40 patterns are black, white, orange, and VIDO— VID5 are direct addressing inputs to blue. A3— A8 of the video ROM. VID6 and VID7 are indi- InHIRESSO processing there is no delay feature- rect addressing inputs, processed first in the lOU to it is not necessary because, with the higher resolu- implement FLASHING text and the functions of tion, the delay colors and other colors can be the ALTCHRSET soft switch. Processed VID6 and generated. Display memory bit 7 has no effect in VID7 are labeled RA9 and RAIO (ROM Address 9 HIRES80 mode. and 10) and connected to the A9 and A 10 address inputs to the video ROM. The other address inputs to VIDEO GENERATOR HARDWARE the video ROM are SEGA, SEGB, SEGC, and GR+2 from the lOU. Additionally, WNDW' from the lOU The video generator consists of circuits that men i- and ENVID' from the auxiliary slotarechipenable tor the video scanner, the display mode soft switches, inputs to the video ROM. and the data driven from the display map in RAM to The control inputs to the video ROM which come produce the VIDEO signal. This includes a consid- from the lOU are gated by video scanner states. erable amount of logic circuitry in the lOU plus the These signals are delayed by one or two video , video ROM, PICTURE signal load/shift register, scanner clocks (RAS' rising during PHASE 1) for ■:and video summing amplifier. Figure 8.5 is a sche- overall timing alignment. For example, SEGC is ;matic diagram of these circuits. simply VC from the video scanner, delayed one ■ Akeyconceptin Applelle video generation isthat scanner clock. The reason for the delay is that it joi a video counter scanning memory to drive out a takes time for data from video scanner access to display map in synchronization with the scanningof RAM to become valid at VIDO— VID7. The delay in an electron beam across the face of a CRT. In Chap- the video scanner signals causes video data and con- ter 5,it was shown how the video scanner outputs trol signals from the same video scanner state to be areaddressing inputs to motherboard and auxiliary present at the video ROM at the same time. This is card RAM during PHASE 1. In this chapter, it will particularly important in the case of LORES graph- be seen that all facets of video generation are per- ics since HO patterns are different than HO' patterns. formed insynchronization with the video scanner. The switching related to GRAPHICS/TEXT time Ihis is accomplished by generating signals as a log- switching in M IXED mode is delayed by two scanner ical function of the video scanner inside the lOU. clocks. This is sothatthe last GRAPHICS pattern at :.??5fi. 8-10 Understanding the Apple He i I § S uI > s 6 c iQ B s s lis PS s 5 Video Generation 8-i 1 the lower right of the display window will be video ROM is disabled and a black PICTURE signal entirely shifted out before the timing HAL is con- results. figured for TEXT shifting. MIXED mode switch- The HBL and VBL signals are not outputs of the ing iscovered in a later section of this chapter. lOU, I only deduce their existences because the logi- It is normal to think of horizontal scan lines as cal way to develop WNDW is as a combination of beginning with horizontal sync, but, in the Apple, it HBL and VBL, generated respectively from states is logical to think of horizontal scan lines as begin- of the horizontal and vertical portions of the video ning with the first cycle of HBL. This is because scanner. Also, WNDW is true at exactly the same HBL begins when the horizontal portion of the video scanner states as the HBL + VBL BLANKING gate scanner is preset and when the vertical portion of the original Apple II (plus one scanner clock). On increments. Signals gated by the video scanner tend an oscilloscope, WNDW is seen to consist of 192 to switch just after the display period ends. So as not alternating negative {40 scanner states) and positive to confuse it with the television horizontal scan, the (25 scanner states) levels followed by a very long 65-cycle period beginning with the horizontal preset positive level (4550 scanner states). The long posi- will be referred to in the following discussion as the tive level is the vertical blanking period, and the horizontal period. short duration alternations are the alternating hori- zontal display and horizontal blanking periods. Inputs to the Video ROM VIDO— VID5 are address inputs to the video ENVID' is a pulled down line connected from pin ROM as mentioned previously. The video ROM 29 of the auxiliary slot to an enable input of the video translates VIDO— VID5(and VID6— VID7, present ROM. The data output lines of the video ROM are via RA9 and RAlO) to dot patterns for loading and pulled up, so disabling the ROM yields high data shifting to the PICTURE signal. The general pro- which represents a black picture. An auxiliary card cess isfor the video to translate data from the dis- can, therefore, blank the motherboard PICTURE play map on VIDO— VID7 to dot patterns as dictated signal by bringing ENVID' high. Also, an auxiliary by other address inputs {GR+2, SEGA. SEGB, and SEGC). card can inject an alternate inverted picture signal to the motherboard on ALTVID'. The GR signal in Figure 8.5 is not the reset state of The fact that a high level out of the video ROM the TEXT/GRAPHICS soft switch. Rather it rep- represents a black level on the screen is simply a resents GRAPHICS time, which is all of the time in matter of hardware convenience. "Black equals GRAPHICS NOMIX mode and all times except V4 high" polarity here makes it easy to blank the dis- . V2 of GRAPHICS MIXED mode. V4 • V2 identi- play via pull-up resistors, and results in proper fies TEXT time in MIXED mode, and it is true polarity of dot patterns at the video summing ampli- during the last 32 horizontal periods of VBL' and fier. Aside effect is that dot patterns in the video during the last 38 undisplayed horizontal periods of ROM are inverted from the polarity in which VBL. This means that in MIXED mode the Apple GRAPHICS patterns are stored in the RAM display switches to GRAPHICS then back to TEXT during map. In HIRES or LORES patterns stored in RAM, VBL, but it is not significant because the screen is "1" represents illumination and "0" represents blank during VBL. blanking. GR+1 and GR+2 are the GR signal, delayed by one The ENVID' line is also connected through the X2 and two scanner clocks respectively. GR+1 is used in jumper to an addressing inputof the keyboard ROM identifying HIRES time for scanner addressing on Revision B motherboards, so pulling ENVID' (Figure 5.3) and in signal selection for SEGA and high also selects the alternate keyboard layout (see SEGB. GR+2 identifies GRAPHICS time in RA9 'Figure 7.4). Additionally, you can install a jack at and RAlO generation and is the GRAPHICS time the J19 location and plug an ENVID' switch into it, output of the lOU. As an addressing input, GR+2 or you can solder jumper X3 and control ENVID' divides the video ROM into GRAPHICS patterns from a program via AN2. and TEXT patterns. / WNDW is the blanking gate of the Apple He, the GR+2 is also a direct input to the timing HAL on Signal which blanks the picture to cause the black Revision A motherboards where it inhibits DOU- ^margin around the display window. It goes high BLE-RES timing during GRAPHICS time. In whenever HBL or VBL inside the lOU goes true Revision B, GR+2 is inverted and gated by FRCTXT' Inn r^ scanner clock). WNDW is connected from before application to the timing HAL. If FRCTXT' y U-38 to the other enable input of the video ROM. is pulled low (normally by resetting AN3 with a 64K Like the ENVID' line, when WNDW is high, the RAM card installed in the auxiliary slot), gated ''""■■»^A 8-12 Understanding the Apple He Table 6.i GR+2' is forced high. This enables DOUBLE-RES VC SEGC SEGA, SEGB, SEGC Signal Assignments.* timing in the HAL if 80COL is set. VC SEGA, SEGB, and SEGC are addressing inputs SEGB to the video ROM which subdivide the ROM differ- SEGA VB ently depending on whether it is TEXT time or VA GRAPHICS time as identified by GR+1. The SEGA, GR+r HO SEGB, and SEGC signals are selected as listed in Tkble 8.1, then delayed one scanner clock before GR+1 •Selected signals are delayed one scanner clock before leaving the lOU. being output from lOU. The TEXT time assignments are such that SEGA, HIRES' GRAPHICS is corrected, and that is why HO is an SEGB, and SEGC determine which of eight seg- ments of a 7 X 8 text pattern is being drawn. Recall addressing input to the video ROM duringORAPH- 1 that VA, VB, and VC are not addressing inputs to ICS time. RAM in TEXT/LORES scanning so the same 40 The correction consists of storing LORES pat- bytes of display memory are scanned eight times terns shifted two bits in the HO areas of the video consecutively for each line of text or pair of LORES ROM. Continuing the above example with 1011 block rows. The assignment of VA, VB, and VC 1000 on the video data bus, the LORES, VC, HO during TEXT time means that SEGA, SEGB, and pattern is 1101 1101 (1000 inverted and rotated two SEGC determine which of eight segments of a 7 x 8 bits). The LORES, VC, HO pattern is 0001 0001 text pattern is to be driven out of the video ROM. (1011 inverted and rotated two bits). The 2-bit bias is Since these text segment address lines are con- equivalent to ^k cycle of COLOR REFERENCE nected to the three least significant address inputs which is the required correction. of the video ROM, you will find the eight segments of The third addressing input during GRAPHICS each character pattern stored adjacently if you time is HIRES', the inversion of the HIRES soft examine the text areas of the video ROM. switch. This is needed at the video ROM because During GRAPHICS time, there is no need to iden- HIRES 7-dot patterns must be routed through the tify each segment of the text lines, but there is need video ROM without regard to VC and HO. If you for other identification. VC is still needed to deter- examine the HIRES GRAPHICS areas of the video mine whether it is time to display the upper or lower ROM, you will find that there is no difference row of LORES blocks. The LORES VC area of the video ROM contains a map of the patterns on between VC and VC patterns or HO' and HO VIDO— VID3, and the LORES VC area contains a patterns. The SEGB output of the lOU is also routed to the map of the patterns on VID4— VID7. As an ex- timing HAL where it is used to distinguish between ample, ifVID7— VIDO descending is 1011 1000, the HIRES and LORES when gated GR+2' is low LORES, VC. HO' output of the video ROM is OUl (GRAPHICS time). The timing HAL needs to iden- 0111 (the inversion of the pattern in VID3— VIDO). tify HIRES40 GRAPHICS so it can delay HIRES The LORES, VC, HO' pattern is 0100 0100. It will be timing by one 14M period if VID7 is high. This is the seen later that the shift/load register rotates* these way the HIRES delayed feature is implemented in LORES patterns at a 14 MHz rate, effectively shift- the Apple lie. ing the 4-bit pattern to the PICTURE signal 3.5 The HIRES patterns stored in the video ROM are times in a LORES40 cycle. The presence of HO as an addressing input satis- simple inversions of the patterns on VID6--VID0. The state of VID7 does not affect the HIRES pattern fies LORES requirements. Recall from Chapter 3 from the ROM because VID7 is the HIRES delay that the beginning phase of the 3.58 MHz COLOR bit, not the on/off condition of a dot. As it is with HO REFERENCE alternates 180 degrees every MPU cycle, and that this phase can be defined in terms of and VC, the VID7' and VID7 portions of the HIRES area of the video ROM are identical. Similary, the HO. The color of a GRAPHICS pattern is different when driven from an even location than it is when MSB of HIRES patterns from the video ROM is not driven from an odd location if no correction is made used. In the video ROM supplied with the Apple He, the MSB is set on all HIRES patterns. for the aiternatingphase of COLOR REFERENCE. There is no correction in HIRES, so even patterns The remaining address inputs to the video ROM are of different color than odd patterns. LORES are RA9 and RAIO. Like SEGA, SEGB, and SEGC, the functions of RA9 and RAIO depend on whether it *In this chapter, the term "rotate" is used in the same sense that is GRAPHICS or TEXT time. During GRAPHICS "rotating" bits is used in 6502 assembly lan^age. time as identified by GR+2, and during TEXT time .-;'''iifi.', , Vim- :?'■ Video Generation 8-13 when ALTCHRSET is set, RA9 and RAIO are equiv INVERSE, and 64 FLASHING characters. Stored alent to VID6 and VID7, respectively (with lOU code for INVERSE characters is identical to that of propagation delay). During GRAPHICS time, this NORMAL characters except VID7 is high for NOR- allows the video ROM to translate HIRES and MAL characters and low for INVERSE characters. LORES VID7-VID0 GRAPHICS patterns into T^ble 8.4 shows the characters of the video ROM Inverted patterns as described above, with direct that correspond to code stored in the display map. map through of HIRES patterns and VC/HO varia- The ALTCHRSET layout seems far more logical tions ofLORES patterns. since it is simply a complete INVERSE set and a Table 8.2 shows the TEXT and GRAPHICS time complete NORMAL set. In fact, the TEXT area of signal assignments to RAIO and RA9. Note that the video ROM is exactly like the ALTCHRSET RAIO and RA9 are equivalent to VID7 and VID6 portion of Table 8.4. That is, RAIO, RA9, and VID5 : except during TEXT time when ALTCHRSET is divide the TEXT area of the video ROM as follows: reset. The special logic is necessary to implement RAIO RA09 VID5 CHARACTER SET I FLASHING text, and because there are differences ! in the character code when ALTCHRSET is reset. 0 0 0 INVERSE control (upper) J Based on the Table 8.2 signal assignments, the 0 0 1 INVERSE special : TEXT time RA9 and RAIO states for various states 0 1 0 INVERSE upper of VID6, VID7, and ALTCHRSET are compiled in 0 1 1 INVERSE lower , "Eible 8.3. 1 0 0 NORMAL control (upper) 1 0 1 NORMAL special ■a little Thereinvolved.is logic toForthestarters, 1 1 NORMAL upper RAIO andeachRA9TEXT states, but it is character 0 1 1 1 NORMAL lower is represented in the Apple display map by an 8-bit word. This means 256 possible character represen- There are no FLASHING text patterns stored in tations can be present on VID7— VIDO in TEXT the video ROM. Flashing text is mechanized by processing. However, there are only 128 characters switching the RAID and RA9 address between 00 in a standard ASCII set, the control, special/ and 10 for that video data with VID7 low and VID6 numeric, upper case, and lower case groups. As a high when ALTCHRSET is reset. Switching be- result, two complete alternate sets of ASCII can be tween 10 and 00 alternately selects NORMAL represented in the TEXT display map. Additionally, control/special and INVERSE control/special char- the ALTCHRSET soft switch enables a programmer acters. The control characters in the Apple lie video to select between two methods of interpreting the ROM are identical to uppercase alphabetic charac- TEXT display code. ters, so the flashing text switches between IN- The original Apple II displayed only 64 upper VERSE and NORMAL upper case, numeric, and case alphabetic, numeric, and special characters special characters. The FLASH signal toggles once represented by the lower 6 bits of video data from for every 16 video scanner overflows (Figure 3.8), so the display map. The two most significant bits were FLASHING text switches back and forth at a 1.87 interpreted by the video generator to display the Hz rate (3,74 alternations per second). characters as NORMAL, INVERSE, or FLASH- ALTCHRSET' INVERSE and FLASHING text ING text. The Apple He TEXT display is compat- is coded differently than NORMAL text and ible with the old Apple II format when ALTCHRSET ALTCHRSET INVERSE text. VID5 is high for is reset, The only difference is that thecomplete 128 uppercase and low for special and numeric charac- NORMAL character set can be displayed, not just ters with ALTCHRSET' INVERSE and FLASH- the upper case, special set. ING text, but VID5 is low for uppercase and high When ALTCHRSET is set, the video data is inter- for special and numeric characters with NORMAL »^^d as 128 NORMAL characters and 128 IN- and ALTCHRSET INVERSE text. As a result. ^'ERSE characters, instead of 128 NORMAL, 64 video output routines should make appropriate Table 82 RA9, RAIO Signal Assignments. GR+2 ALTCHRSET RAIO RA9 VID7 VID6 1 X 0 0 VID7 + VID6* FLASH VID6.VID7 0 1 VID7 VID6 8-14 Understanding the Apple He Table 83 RA9,RA10 TEXT Time States. VID6 RAIO RA9 CHARACTERS ALTCHRSET VID7 0 0 0 0 0 INVERSE control/special 0 0 1 0 Flash INVERSE/NORMAL* FLASH 0 NORMAL control/special 0 1 0 1 0 1 1 1 1 NORMAL upper/lower 1 0 0 0 0 INVERSE control/special 1 0 1 0 1 INVERSE upper/lower 1 1 0 1 0 NORMAL control/special 1 1 1 1 1 NORMAL upper/lower ♦Flashes between NORMj \L control/special and INVERSE control/special. transformations to store correct code for desired mode, because new data is always loaded before the INVERSE or FLASHING characters in the dis- old data is completely rotated in the other modes. play area. The 40-column firmware of the Apple lie The loading and shifting of dot patterns is con- does not correctly output lower case INVERSE trolled bythree signals from the timing generator, video for display with ALTCHRSET set because it LDPS', VID7M, and 14M. LDPS' is the load/shift was written for the Apple II, not the Apple He. The control as noted before, 14M is the load/shift regis- 80-co!umn firmware supports ALTCHRSET text, ter clock, and VID7M serves as the clock enable but it outputs INVERSE characters correctly only (since it slightly lags 14M). The register loads or if ALCHRSET is set. In other words, use the 80- shifts data every time 14M rises when VID7M is column firmware to output lower case INVERSE low. The timing generator brings VID7M continu- text from your Applesoft programs, but use the 40- ously low during DOUBLE-RES modes and column firmware if you wish to mix INVERSE and LORES40 mode to enable 14 MHz processing. Dur- FLASHING text. ing TEXT40 and HIRES40 modes, VID7M is low every other 14M rising, so processing is at 7 MHz, Loading and Shifting of Dot Patterns Note that auxiliary patterns appear at the input For each 1-microsecond period between rising lines of the shift register every 500 nanoseconds, edg-es of PHASE 0, there are two 500-nanosecond regardless of the Apple He display mode (assuming accesses to the video ROM. Video data from the an auxiliary RAM card is installed), However, in auxiliary card becomes valid on the video data bus SINGLE-RES mode processing, the timinggenera- shortly after PHASE 0 rises and remains there until tor does not bring LDPS' low at the end of PHASE 0, shortly after PHASE 0 falls. Also, shortly after so the auxiliary RAM pattern is not processed. Dis- PHASE 0 falls, video data from the same mother- play mode control is thus maintained via timing board RAM address becomes valid and remains generator signals. More details of these timing sig- valid until shortly after PHASE 0 rises. The pattern nals will be discussed in following sections. from the video ROM takes no more than 450 nano- seconds tobecome valid after its address is valid The QH output of the load/shift register is con- (assuming Apple uses a450 nsec ROM), so the auxil- nected tothe PICTURE' line, so the PICTURE' line rises and falls as a function of the rotating dot pat- iary card pattern is valid toward theend of PHASE terns. IfQH is low or if the ALTVID' line from the 0, and the motherboard pattern is valid toward the auxiliary slot is low, the PICTURE signal goes high, end of PHASE 1. a level that results in illumination on the television The output of the video ROM is connected to a screen. The least significant bit from the video ROM 74 LSI 66 load/shift register that loads the dot pat- is connected to the QH input of the load/shift regis- terns and shifts them out, The patterns are loaded ter, so it is logical to think of QH as the least signifi- when LDPS' drops low near the end of PHASE 0 (if cant bit. It can then be clearly stated that patterns DOUBLE-RES) and near the end of PHASE 1 are nal. shifted LSB first. with inversion to the PICTURE sig- (always). When the 8-bit load/shift register is not loading data, it is rotatingthe data in an end around shift. The rotation is only important in LORES40 The PICTURE signal is applied to the video summing amplifier through a resistor that biases it illli"^ Video Generation 8-15 Table 84 Displayed Text Characters. ALTCHBSET' INVERSE FIASH HORHAL UPPER SPECIAL UPPER LOWER SPECIAL C(»ITR0L SPECIAL UPPER 000 016 032 048 064 0B0 096 112 128 144 160 176 192 208 224 240 ASCII $40 550 $60 570 $80 A $90 5A0 $B0 500 0 $0 50t> P 510 520 0 $30 A@ PQ 0 Q 0 @ $D0 P \ p 1 $1 A Q 1 1 1 1 e P 1 1 A 0 a B R q 2 52 B R 2 B R 2 2 B R b r 3 $3 C S # 3 C S # 3 C S C S c s # 3 $F0 4 $4 D T $ 4 Li D T D T D T $E0 d t 5 $5 E U % 5 E U $% 45 E U % 6 $6 F V & 6 F V S 45 E U e u E, 6 F V & 6 F V f V 7 $7 G w 1 7 G W 7 G W 7 G w g w 8 $8 H X { 8 H X * H X H X h X 9 $9 I y ) 9 I Y ( 8! I Y I Y i Y 10 $A J z * « J K Z[ ) + 9; J K L Z[ \ «( ) 89 J 7, j z 11 ?B K L + / L \ M ] + K r k ( 12 $C L < \ - 1 M ] - =< < L \ 1 \ *J 13 $D M = 14 ?E N . > M ] ID } N > N > N n 15 $F 0 — / ? O 0 0 o :s - / ? / ? ALTCHRSET INVERSE NORMAL UPPER SPECIAL SPECIAL UPPER LOWER CONTROL UPPER LOWER 000 016 032 048 064 080 096 112 128 144 S0 176 192 208 224 240 ASCII ^0 $B0 $40 550 $60 a $70 q $80 590 $C0 $D0 0 $0 @ $00 510 p 0 P 1< 0 A Q $E0 % $F0 $20 $30 A@ QP A@ QP P 1 $1 A Q 1 1 I 1 @ P a q 2 $2 B R ri 2 B R b r B R 2 B R b r 3 S3 C S # 3 C S c s C S C S c s 4 $4 D T 5 4 D T d t D T * 3 D T d t ■ 5 S5 E U % 5 E U E U e u ?i 45 E U e u 6 56 F V & 6 F V f V F V 6 F V f V i 7 57 G w ' 7 G W i G W 7 G W q w H X ( 8 H X h Xy H X 8 H X h X * 9! 59 !® I Y ) 9 I Y g w 1 Y 95i I Y i y 10 5A J Z * ; J Z J K Z[ K J Z\[ z 11 5B K [ k { L j K C + L \ 1J L \ - M0 3_ V ( 12 $C ■13 5D L \ # < z1 MO ] < 1 \ M 3 - = H ] m 1 _ = m ) N A * > N n > N n ^1 ?^F^ I 0 - ? O O S£ ? o !« P WOTES: K checkerboard N " "Mouse text" replaces letters and characters at ASCII = $40— $5P in the enhanced firmware video ROM (see Chapter 6, The Apple He Firmware Upgrade). jiS-i'-S-**J. 8-16 Understanding the Apple He operate in any country by installing a power sunnW to the correct voltage amplitude relative to SYNC that would operate from the line voltage of that and COLOR BURST'. The three signals— PIC- country. Supporting the special text requirements TURE, SYNC, and COLOR BURST'— are summed of the various languages is no problem because you together to make up the Apple He VIDEO signal of Figure 8.2. The VIDEO signal is routed from the can simply plug in a keyboard ROM and video ROM summing amplifier to J12, J13, and Jll. the video for any language. The unfortunate reality is that there are several output jack at the back of the Apple. SYNC is a direct output of the lOU, generated television systems used throughout the world, in- from states of the video scanner. It is a combination compatible with each other to one degree or another. One area of incompatibility is the scanning rate, The of horizontal sync (a four scanner state pulse occur- NTSC standard scanning pattern is made up of 525 ring in the middle of HBL) and vertical sync (four 56-state pulses occurring in the middle of VBL). For horizontal scans in two interlaced fields scanned at the American Apple, Figure 8.2 shows horizontal 60 fields per second. Other television systems have and vertical sync detail. Figure 8.5 shows the pictures made up of 625 horizontal scans in two SYNC logic equation, and the Figure 5.9 memory interlaced fields scanned at 50 fields per second. scanning map shows exactly when SYNC occurs. Apple lie compatibility with televisions and moni- COLOR BURST' is a 14-cyc!e (four video scanner tors designed to scan at the slower rate is achieved states) inverted sample of the COLOR REFER- through installation of a 50 Hz lOU, as opposed to ENCE signal. It is gated by CLRGATE' from the the 60 Hz lOU of American Apples. lOU which drops low immediately after horizontal In the 50 Hz lOU, the vertical portion of the video sync if theTEXTsoftswitch is reset(see Figure 8.2). scanner presets to OUOOIOOO, fifty less than the 60 CLRGATE' never drops low ifTEXT is set, so there Hz Oil 1 UOIO. This adds 50 scans to the normal 262 is no COLOR BURST, and consequently no undesir- for 312 horizontal scans in a 50 Hz Apple. All 50 of able coloring of screen characters, in TEXT mode. these scans are added to VBL so that VBL is 120 ColoringofTEXTcharactera does occur in MIXED scans long instead of 70. Additionally, the vertical GRAPHICS mode because the COLOR BURST is sync is shifted from that of the 60 Hz lOU so equal not turned off, even during TEXT time. black margins are maintained at the top and bottom SYNC and CLRGATE' transitions do not occur of the screen, Horizontal scanning and sync are the quickly after the video scanner states, but appear to same in both lOUs. be clocked out by Q3 falling during PHASE 0. I The vertical sync equation in 50 Hz lOUsis VBL» speculate that this is done to remove gate width V5' • V2' • VO' . VC • (H5 -^ H4 + H3) as opposed to variations and switching spikes that can occur in VBL.V2.Vl'.VO'.VC.(H5-^H4-^H3)in60H^ logic gating. There is very good basis for this specu- lOUs. Vertical syne consists of four 56-state pulses, lation because a switchingspikeon the vertical sync just as in American Apple scanning. These occur line causes a visible dark line in the left hand blank- dur ing horizontal periods 73, 74, 75, and 76 of VBL ing margin of older Apple lis. I'm sure that Apple is in 60 Hz Apple scanning. By way of comparison, 60 rightly wary of reintroducing a problem that they Hz lOUs have 36 horizontal periods in VBL up once solved. through vertical sync and 34 horizontal periods in VBL afterwards. 50 Hz lOUs have 76 horizontal Video Generation in Export Appies periods in VBL up through vertical sync and 44 The differences between foreign and American horizontal periods in VBL afterwards. "m Apples are related primarily to video scanning and The critical states of VA— V5 in both 60 Hz and 50 VIDEO signal generation. If not for television sys- Hz lOUs are summarized in Table 8.5. Old Apple tem incompatibility, the Apple lie could be made to hands may recognize that Apple He 60 Hz scanning Table 85 American (60 Hz) and European (50 Hz) Scanning Differences. VERTICAL PEIESET ON VERTICAL START VBL SYNC OVERFLOW V5432i0CBA SYNC V543210CBA V543210CBA American H1000000 H11000XX 011111010 V543210CBA END VBL V54321gCBA. European 1.11000000 011001000 0110100XX 100000000 100000000 \l:-\:^\ ,:-«*ll' Video Generation 8-1 7 is identical to that of the RFI Revision Apple II. and designed to display PAL video will not, therefore, that 50 Hz scanning is identical to that of the RFI automatically produce colored displays from 3.56 Revision Apple II with 50 Hz jumpers made. MHz Apple He dot patterns interspersed with 3.56 The 50 Hz scanning of foreign Apples is fine tuned MHz REFERENCE BURSTS. To generate a signal by changingthe 14 MHz crystal on motherboards in that will produce a color display on a PAL monitor, which 50 Hz lOUs are installed. The frequency is the PAL circuitry extracts color information from changed from 14.31818 to 14.25045 in motherboards the serial dot pattern and 3.56 MHz COLOR REF- with discrete circuit oscillators, and to 14.25 in ERENCE, Then a PAL VIDEO output signal is motherboards with hybrid circuitosciliators(and in constructed with luminance signal, modulated 4.44 50 Hz Apple He's). This is done so that the Apple lie MHz color subcarrier, phase alternating 4.44 MHz horizontal scan period is approximately equal to the COLOR BURST, and scanning sync* 64-microseeond horizontal period of 50 Hz television systems. The dot patterns on the PICTURE' (SEROUT') line are shifted at 14 MHz to an LS164 serial in, Changing 14M slightly alters the 6502 execution parallel out shift register and sampled as 4-dot pat- speed (from 1.0205 MHz to 1.016 MHz) and reduces terns, four dots being the number of HIRES80 dots COLOR REFERENCE to 3.56 MHz. The 6502 in a COLOR REFERENCE cycle. Every time speed reduction is apparently not enough to make COLOR REFERENCE rises, a new 4-dot pattern is disk I/O unreliable when reading American disks latched in an LS175 quad D flip-flop. The output of on 50 Hz Apples or vice versa. The reduction in the four flip-flops is a 4-bit number which repre- COLOR REFERENCE frequency is not important sents the phase relationship between the current because, while COLOR REFERENCE is the refer- 4-dot pattern and COLOR REFERENCE, in other ence for color on the PICTURE' line in 50 Hz words, the color of the Apple He dot pattern. Apples, it is not of the frequency at which color is The 4-bit color word is converted through sum- passed to a television or monitor. ming re.sistors to DC voltage levels representing The second important area of incompatibility in weighted R-Y (red minus luminance) and B-Y television systems is the different methods of rep- (blue minus luminance) color signals. These are the resenting color information. The three principle color signals which are used to modulate a subcar- systems are NTSC, PAL (Phase Alternating Lines), rier in conventional PAL broadca.=?t television. The and SECAM (SEquential Color And Memory). color signals are summed with modulator balance There are no Apple He SECAM adaptors, but the voltages and burst gate voltages, and applied to the Apple He is used in some SECAM countries using R-Y and B-Y reference inputsofaTCA6,50 chromi- RGB adaptors and monitors. This is especially true nance demodulator. of France, whose television sets have an RGB input The TCA650 is an IC that is intended for use as a jack (the Peritel jack) in the back. PAL is the system synchronous demodulator in PAL or SECAM tele- used in European Economic Community countries vision sets. In the Apple He PAL circuitry, the {except France), and Apple competes in this impor- TCA650 is used for exactly the opposite function, tant computer marketplace by manufacturing an modulating a constant phase subcarrier with B-Y, Apple He PAL motherboard. modulating a phase alternated subcarrier with Figure 8.6 is a schematic of the circuitry that is R— Y, and combining the two modulated subcarri- idded to an NTSC motherboard to make it a PAL ers to form the chrominance signal. This is not a motherboard. This figure is an Apple drawing, re- norma! TCA650 application but an impressively produced here with permission of Apple Computer, innovative design effort by Gary Baker, the Apple ,'.nc. The notes in italics and the video ROM and engineer who designed the Eurocolor card. Rather teyboard ROM depictions were inserted by this than cause confusion by insisting that the TCA650 is ^uthor. The PAL circuitry is nearly identical to the a demodulator, I will refer to it as a modulator with ■ircuitry of the Apple II "Eurocolor" card, so basi- modulating inputs at pins 6 and 7 and subcarrier ally an Apple He PAL motherboard is an Ameri- inputs at pins 11 and 9. an motherboard with a 14.25 MHz oscillator, a 50 The color subcarrier comes from a 4.43619 MHz ■m* ^' ^'*''^'^" language video and keyboard oscillator and is applied to pin 1 of the TC A650. It is ^^"JMs, and a built-in Eurocolor card. ^ PAL video usesa4.43619 MHz color subcarrier as *The 4.44 MHz signal should be referred to as a carrier to be technically correct, It becomes a subcarrier if the VIDEO signal l?M ^ ^^^ 3-579545 of NTSC, and the PAL tnodulates a television RF carrier. However, referring to this jUi^UR BURST alternates 90 degrees in PHASE signal as the subcarrier helps to disting-uish it from the RF wety horizontal scan. Televisions and monitors carrier, and so shall it be here. **^^!i:i. ' ■'«-■(( lu. 8-18 Understanding the Apple lie S-— f Si S3 * ,, ajJV 0 E 0 S ^^^J i.-t K->«y3?' Video Generation 8-19 output at pins 13 and 15 at equal amplitude. The 2732 compatible ROM of American Apples. A sim- constant phase pin 13 output is routed through 90 ple switch line (ALTCHR) connected to address degree phase shifting circuitry to pin 9, the subcar- inputs of the keyboard and video ROMs switches rier input to the B-Y modulator. The pin 15 output between American and foreign language text char- alternates its phase as controlled by the pin 16 acters. With the big video ROM, there truly are switching input. This input toggles when CLRGATE' complete alternate text character sets to choose falls, so the pin 15 signal alternates in phase every from in the PAL Apple He. horizontal scan. The phase alternating output from There are some countries (Canada for example) pin 15 is coupled to pin 11, the subearrier input to which use the NTSC standard television system but the R— Y modulator. still have foreign language requirements. To sup- The 90 degree shifted, B-Y modulated subear- port the bilingual needs of these countries, Apple rier and the phase alternated, R— Y modulated sub- developed a 24- to 28-pin socket adaptor for the video carrier are combined together at pins 10 and 12 of ROM socket of the NTSC motherboard. When Apple the TCA650. This signal is a combined CHROMI- begins to support a bilingual NTSC market like NANCE/BURST signal. The BURST is generated this, they use the adaptor to enable installation of by level shifting the B~Y and R-Y signals in oppo- 28-pin 2764 bijigual video EPROMs. However, if site polarity during CLRGATE' low. The modula- the market gets big enough to .justify it, they mask tion balance controls are ad.justed so there is no the bilingual patterns intoa24-pin, 8 kilobyte ROM. chrominance signal out of the TCA650 when the I am not certain how to obtain oneof the adaptors in 4-bit color word is 1111 and CLRGATE' is high. the U.S., but it would not be particularly difficult to build an adaptor like this if you desire to switch When CLRGATE' drops low, B-Y raises and R-Y between displayed text character sets in an NTSC lowers to cause a 4-microsecond sample of the 4.4 MHz subearrier to appear at pins 10 and 12 of the Apple He (see Figure 8.18). TCA650. Combining the 180 degree phase alter- nated subearrier and the 90 degree shifted subear- DISPLAY MODE SOR SWITCHES rier together in equal amplitude results in a COLOR BURST that alternates 90 degrees in phase every The display mode of the Apple is set up by pro- horizontal scan. grammable soft switches in the lOU. The lOU soft The serial dot pattern on PICTURE', delayed by switches are illustrated in Figure 7.1, and the func- the LS164 shift register, is inverted to form the tions of those soft switches related to the video dis- LUMINANCE signal which is summed with the play are summarized in Table 8.6. SYNC and CHROMINANCE/BURST signals to There are three basic disi)lay modes, TEXT, produce the PAL VIDEO output signal. There is a LORESgraphics, and HIRES graphics selected via gated trap which removes 3.56 MHz variations from the TEXT (GRAPHICS') and HIRES (LORES') the LUMINANCE signal during GRAPHICS time soft switches. Additionally, MIXF]D displays of when the COLOUR/MONO switch is set to COLOUR. HIRES or LORES with four lines of text at the This is necessary to prevent 3.56 MHz LUMI- bottom of the screen mav be selected bv resetting NANCE patterns from causing color interference TEXT and setting MIXED. since 3.56 MHz is within the bandwidth of the PAGE2 selects between the PA(5E1 ($400-$7FF chrominance amplifier ofa PAL monitor or television. and $2000-.?3FFF)and PAGE2 {.$800— $BFF and Trapping3.56 MHz from the LUMINANCE sig- $4000— $5FFF).scanned display areas if 80STORE nal causes 3.56 M Hz dot patterns to be blurred. This is reset. If 8()ST0RE is .set, PA(;E2 performs the -enhances colored solids on the screen but prevents motherboard/auxiliary RAM access management . clear displayof high resolution monochrome graph- functions described in Chapter 5. ics. The COLOUR/MONO switch should, therefore, The 80COL soft switch performs only one func- be set to MONO when the Apple He is used with a tion. It is inverted to SOC'OL' and output from the -monochrome monitor. In addition to disabling the lOU to the timing HAL where it selects DOUBLE- 3.56 MHz trap, thisdisablestheCHROMINANCE/ RES timing if GR+2 is low in Revision A or gated BURST signal from the TCA650. GR+2' is high in Revision B. In other words, DOU- \ Besides the PAL circuitry, there are differences BLE-RES timing is enabled when 80COL' is low i n the keyboard and video ROMs of the PAL moth- during TEXT time or forced (by FRCTXT') TEXT erboard of which Americans can be justifiably time. On Revision B motherboards with a64K RAM invious. The video ROM is an 8 kilobyte, 28-pin 2764 card with DOUBLE-RES GRAPHICS jumper in- ;ompatible ROM instead of the 4 kilobyte, 24-pin stalled, FRCTXT' is brought low to force gated ?^3 8-20 Understanding the Apple lie Table flj6 Functions of the Display Mode Soft Switches. SOFT OFF ON READ FUNCTION SWITCH ADDRESS ADDRESS ADDRESS Disable PAGE2 display area switching 80STORE* w$cooo wscooi R$C018 80COL w$cooc W$COOD R$C01F DOUBLE-RES timing if TEXT time or AN3' ' ALTCHRSET R$C01E Display full INVERSE ASCII text set W$COOE W$COOF TEXT display R$001A TEXT*** $C050 $0051 MIXED GRAPHICS/TEXT display if TEXT' MIXED*** $C052 $0053 R$001B Scan secondary RAM display area PAGE2* $0054 $C055 R$C01C HIRES display if GRAPHICS time HIRES* $0056 $C057 R$C01D NA DOUBLE-RES GRAPHICS timing when AN3' $C05E AN3** $C05F NOTES- * PAGE2, HIRES, and 80STORE are mechanized identically in the MMU and lOU. The MMU passes the state of 80STORE to MD7 when $C018 is read, and the lOU passes the state of PAGE2 or HIRES to MD7 when $0010 or $C01D is read. ** AN3 is jumpered to the FRCTXT' (ENFIRM in Rev A) line on 64K auxiliary RAM cards. When AN3 is low, this forces gated GR+2' high at the timing HAL. enabling DOUBLE-RES timing if 80COL' is low. *** All Tkble 8.6 soft switches except TEXT and MIXED are reset when RESET' falls. GR+2' high by resetting AN3. On Revision A moth- HIRES40 MIXED WITH TEXT40, PAGEl erboards, there is no FRCTXT' line and no way to LDA $C050 TEXT OFF (GRAPHICS) display DOUBLE-RES GRAPHICS. LDA $0053 MDCED Now that the video generator hardware has been IDA $0054 PAGE2 OFF introduced, there is a basis for understanding how LDA SC057 HIRES soft switches control the display modes of the Apple IDA $C05F AN3 CM {ENABLE HIRES He. First, they affect RAM addressing so that they EELAYED) control the area of RAM which is being scanned during PHASE 1. Second, they affect video ROM STA $C00C 80COL OFF (NO DOUBLE-RES) addressing so that they control the translation of video data to dot patterns. Third, they affect timing HIRES80 GRAPHICS, bKMIX, PW3E1 generation so that the PICTURE signal is loaded IDA $C050 TEXT OFF (GRAPHICS) IDA $C052 MIXED OFF and shifted at SINGLE-RES or DOUBLE-RES HIRES IDA $C057 rates. Table 8.7 shows the various display mode con- IDA $C05E trol soft switches and how they accomplish their AN3 OFF (DOUBLE-RES functions. GRAPHICS TIMING) The following programming examples should STA $Q301 SCAN) aaSTORE (DISABI£ PAGE2 serve to illustrate the principles of display mode selection in the Apple He. STA $C00D 80OaL (DOUBLE-RES) TEXT40, PAGEl IDA $C051 TEXT IORES40 MIXED WI1H TEXT80, PAGE2 LDA $C054 PAGE2 OFF TEXT OFF (GRAPHICS) IDA $0050 MIXED STA $C00C SBGOL OFF (1«J0 DOUBLE-RES) IDA $C053 IDA $C055 PAGE2 TEDCTBO, PPGE2 IDA $C056 HIRES OFF (DORES) I£A $C051 TEXT IDA $C05F IDA $C055 PAGE2 AN3 CN GRAPHICS (SIN3LE-RES TIMING) STA $C00iD 80C!QL (DOUHLE-BES) STA $C000 SCAN) STA $C000 80SrORE OFF (EM^BU: 80STQRE OFF (Q»ABI£ PBGE2 PAGE2 SCAM) STA $C00D 80CaL (DOUBLE-RES) i s 14M I I I I I I I M I I I I I I I I \ I ■ HO SEGC I \ 1_ "LI 4,0 AUX I VIDBUSMRBD | VID BUS AUX "1 VIDBUSMRBD ' | vmRllSflllV | VID BUS MRBD fTITx 7M COLOR REF VID7M u SINGLE RES ana U LOflO MBD MBD LOAD LOaD EVEN EVEN ' ADJACENT L DPS' LS166 OD DH tiiQ[coii|itKii|n[ic|oiio]Mii|iOQ!|iiK[|oiio|ffln|io(ii|iimfni:i-,|i fciioi«lii]iMi|nmlaim|iic.|lim-l.i«ilniinlmnliiin,liiMi|,'iiir| |01H)|[)a|-]™i|llOO|DllD|QCiil|imilll0o|ci10|'X'il|lM:|llMiWEXT l3in]ioi:li5ffi|iiMlaiii>Ir«ii]Si|iinolfiiin|ff^T "v ODD even 87 lores BY lUU OE-OH l'"'i"t'''i ■|ii»i""ih"i"»']iiij|i)iiiiiiiiii--!"i"»|oiiii ''l■ ■'liini|[niili[iiilii[}i|iiinloniJicii|! nc'nS l'OOOfcloi>Jwirtlcwiitcooli;iMlrflirJOW|!i- l™fesslss;!!lsisil;^ls;sstei?tetel';™' :flr^'^i \'- \ ■ !■ ■-'! :-^.| iS'|i'io|oiiiligiijiioi|iiio|F,uffF!N FOLLOWED LORES PRODUCES VIOLET BORDER PICTURE "Lf I Sififi QA-QD [ioiiciT^^ ^ EVEN LORES 5 i-\j iwij QEQH |tQii^loiO!liEinlDioi|igialflini|inin|oioi|ioiolDioi^r>io|[ticil.ioiQ|[]Toilnrii|joic|ci{ii|icin|oi{iihoic[ai[)i|i(jialoioi|'Oioloioiti^ ODD LORES BY FOLLOWED SA PRODUCES BROWNISH PICTURE " MBD BORDER LOAD LOAD u u ■MBD u DOUBLE RES DDO IHAD AUX -— '- AUK LCi*D \ nam LOAD LOAD LDPS' EVEN ODD MBD AUX MBD fl/EN EVEN LO loo OE-QH D l'»'liiiolr.;iilinnl'iiiiliiiilf,iiiliiDiliii[iloiii]wHl'iDi|iii!i|ari|Diii|iGn|iiD-|iiio|Dri|ia!!|ini|D!--|i(iii|iioi[iiio I LOA iiiiilniii|iici| iiii'|iii[i|o-n|'nii ['ii^i|iiio|niiiiP»nEiin ;\|jX RAM LORES 2 INTERFERES W/ITH pip-riipr ^ — ^^^^^^ I MBD RAM LORES 2 LJilfifi 1A0D -J — ■— '— ' ' ' ' '— L AUX PRODUCE 1l(}lfinoJ011l|lDT-|rol|mr:l[n11 i! !;"!!"■! "S!i;;gg;!!gg.U- 1 ramS lores SAME 2 PICTURE )r RAM COLORLORES AS MBD 4 Figure 8.9 LORES Video Output. 14M I I I I I I I I 1 I I I M 1 M I I I I I I I I I I I IJJ^LLUjjj^ HO VIOBUSIVIRBD I VIDBUSAUX IviDBUS M tl>0 AUX I VIDBUSMRBD VIDBUSAUX 7M _rLrL_n_rLJ LjnLiTrLriJi_JiJiXLJTj~ijuij~LrLr "LT COLOR REF LJ \ m r SINGLE RES <^ UNDELAYED 'VID7 Lf u SINGLE RES DELAYED ^ VID7M LDPS' RXLriJTJ^rLJlJTJlJlJl-JTJTJlJlJlJl LSI 66 ' RE PICTVUID7 J LI i_r IT SINGLE V107M RES < L l__f UrTTXJ~urLJiJ"L_rTJTJ"LJTJi-ri-r"iJ^ DPS COMBO ' LS166 I ^n'l" f loimicil onoiDO' I ii)iioiixi|dioiioi|] I miiiii[ii|™n (iiipmcil i(iiicim| Bienfiial mmm PICTURE rVID7M: LDPS'1_J DOUBLE RES ' Lb mo QE-QHim o|'^'i|m!n|iDn|oioil[ioi(i|m|ioio|noilo'i[)Ti[inl[iiDi|mio|imi|ioio|n()!|0'![)limi|o»i|ooio|t^^ I C1CC QA-OD ,],. .\ .. .[...] .■r,|.T,.|- i;|:i,]„ .j .-.--|jr.:|.r.:jii:,-|rc? — D Q. a i5 O t0) 2 c ■ £ 1 s>e 00 ^0) E B MPU MEMORY MANAGEMENT HI SERIAL I/O ROM ADDRESS DECODE H KEYBOARD RAM SOFT SWITCHES H PERIPH ERAL SLOTS AUXILIARY SLOT $^^ RAM ADDRESS MUX VIDEO SCANNER POWER ^■1 TIMING GEN VIDEO GENERATOR GAME CSSTCSST EXTENDER IN OUT VIDEO i~~> VIDE O 2N3904 02 GAME I/O MM741 D *'^ 21\I3906* I MPU ▲ ▼▲A V X1X2X3X4X5 ■ LS244 LS245 LS244 6502A Revision B LS138 ▼ Ivvl In umpers shown S109 LS10 I KEYBOAPO HAL/16R8 i ^ LS374 U X ENVIO' i A |l I LS125 ^ 05 ^ -C3 0S2 2732 MM m| II 04 2N4258 MPSA13 0 LS166 4164 4164 4164 4164 4164 4164 4164 4164 RAM RAmI a SPEAKER 1 2 6 7 9 10 11 12 13 Video ROM is equivalent to 2764 on PAL motherboard 14 Figure 10.3 Motherboard Component Locations. Video Generation 8-21 Table 8.7 Mechanization of Display Mode Soft Switcties. SOFT RESET SWITCH FUNCTION SET MECHANIZATION TEXT GRAPHICS Scanning of $400-$BFF (Fig 5.3) Segmented addressing of text patterns at video ROM (Fig 8.5) INVERSE, NORMAL, FLASH interpretation of VID6, VID7 (Fig- 8.5) Disable COLOR BURST via CLRGATE' (Fig 8.5) Enable DOUBLE-RES timing (Fig 3.9) MIXED NOMIX Scanned address switched to TEXT at screen bottom (Fig 5.3) Video ROM address switched to TEXT at screen bottom (Fig 8.5) Enable DOUBLE-RES timing at screen bottom (Fig 3.9) PAGE2 PAGEl Scanning of $800-$BFF if TEXT/LORES, 80STORE' (Fig 5.3) Scanning of $4000— $5FFF if HIRES, 80STORE' (Fig 5.3) Aux RAM access at $400-$7FF if 80STORE (Fig 5.13b) Aux RAM access at $2000-$3FFF if 80STORE. HIRES (Fig 5.13b) HIRES LORES Scanning of $2000— $5FFF if GR+1 time (Fig 5.3) HIRES video ROM address if GR+1 time (Fig 8.5) Monitor VID7 for delayed timing if SINGLE-RES, GR+2 (Fig 3.9) PAGE2 selects $2000-?3FFF main/aux RAM if 80STORE (Fig 5.13b) FRCTXT DOUBLE- RES GRAPHICS timing if 80COL (Fig 3.9> FRCTXT' SINGLE-RES, 7MHz. undelayed timing if 80COL' (Figure 3.9) 80STORE Disable PAGE2 dispia.v management functions (Fig 5.3) 80STORE' Enable PAGE2/HIRES memor.v management functions (Fig 5.1.3b) 80COL 40COL Enable DOUBLE-RES TEXT or forced TEXT timing (Fig 3.9) ALTCHR NRMCHR Enable lower case INVERSE video ROM addressing (Fig 8.5) VIDEO GENERATION TIMING SIGNALS The logic equations of the timing H AL outputs are given in Table 3.4. The LDPS' and VID7M entries The video generation timing signals are LDPS' from Table 3.4 are repeated here in Table 8.9 for ease (LoaD Parallel in, Serial out register) and VID7M of reference. These equations are valid for HALs (VIDeo7 MHz). They areoutputsof the timingHAL meant for use in Revision B motherboards. The and were covered superficially in Chapter 3, but Revision A HAL supports GR+2 input instead of they are covered in detail here because they are related solely to the loading and shifting of video GR+2', and there some differences in timing signal patterns. phase. Some important aspects of the Revision B VID7M and LDPS' equations follow here. Refcr- As mentioned previously, LDPS' is the load/shift e nces in parentheses such as (S 1) refer to logic eq ua- control signal for video output and VID7M is the tions in Ikble 8.9. load/shift clock ENABLE' signal. The video load/ shift register loads or shifts when 14M rises while VID7M is low. If 14M rises while VID7M and 1. Gated GR+2' is used to differentiate between TEXT time and GRAPHICS time. This signal LDPS' are low, the video pattern at the output of video ROM is loaded into the load/shift register.theIf is represented by GR' in the logic equations, and it is lowduringGRAPHICS time if FRCTXT is 14M rises while VID7M is low and LDPS' is high, the pattern currently residing in the load/shift reg- high. GR' in the equations is true during TEXT ister isrotated QH > QA, QA > QB, QB > QC, etc. or forced TEXT time, GR" is true during A number of the features of Apple He display GRAPHICS time when FRCTXT' is high. modes are realized through variations of LDPS' and 2. SEGB is equivalent to LORES (HIRES soft VID7M as shown in Table 8.8. These variations will switch reset) during GRAPHICS time, and it is be made more clear as the specific examples of Fig- used in the timing HAL to distinguish between ires 8.7, 8.9, and 8.13 are discussed. LORES and HIRES GRAPHICS. 8-22 Understanding the Apple He Table »5 Display Mode Variations o« VID7M and LDPS'. RESULT MODE VARIATION 7 MHz load/shift TEXT40 VID7M = 7M One video cycle per MPU cycle LDPS' durinff PHASE 1 7 MHz load/shift H1RES40* VID7M = 7MifVID7' Delayed 7 MHz load/shift VID7M = 7M' if VID7 One video cycle per MPU cycle LDPS' during PHASE 1 Video cycle delayed if VID7 LDPS' delayed if VID7 VID7M constant low 14 MHz load/shift LORES40* One video cycle per MPU cycle LDPS' during PHASE 1 14 MHz load/shift DOUBLE-RES MODES VID7M constant low Two video cycles per MPU cycle PHASE h PHASE 0 LDPS' ♦Forced undelayed 7 MHz processinp- if FRCTXT is low. 3. VID7M is constantly low during LORES 8. LDPS' falls only during PHASE 1 of SINGLE- GRAPHICS (SI). This causes 14M LORES pro- RES processing. In DOUBLE-RES processing, cessing at the load/shift register. An abnormal LDPS' falls after AX' • Q3' of both PHASE 0 undelayed 7M LORES mode can be selected by and PHASE 1 (SI). In other words, in DOU- BLE-RES processing, the auxiliary card RAM VID7M i.s80COL resetting identicalandto bringing 7M in thisFRCTXT' mode. low. pattern is loaded, in addition to the mother- 4. VID7M is constantly low during DOUBLE- board RAM pattern, RES (80COL, TEXT or forced TEXT) time 9. During TEXT time (S2), forced TEXT time (S2). (S2), LORES time (S3), undelayed HIRES (S4), 5. If 80COL is reset, VID7M is identical to 7M and at the right edge of the display screen (85), during TEXT or forced TEXT time (S3). This LDPS' falls after PHASE 1 • AX'« Q3'. During forces VID7M to be identical to 7M in TEXT40 a HIRES delayed cycle (S6), LDPS' falls one mode. Incidental side effects are that FRCTXT' 14 M period later causing a delayed load of the low forces undelayed processing of HIRES40. HIRES pattern. and the abnormal 7M LORES processing de- The abnormal 7M LORES mode mentioned in scribed initem 3. 6. Equations SI— S3 cover all VID7M processing items 3 and 5 is largely useless, and knowledge of its except HIRES40, and equations S4— S5 and existence is not widespread. 7M LORES processing T1-T3 cover only HIRES40. At the end of is basically the processing of LORES patterns at HIRES40 speed. It results in fragmented blocksfor PHASE 1 • Q3' • AX' (marked by dots in Fig- ures 3.2 and 8.13) in HIRES40 processing, al 1 patterns except 0000, 0101, 1010, and 1111 which VID7M falls if VID7 is low and does not fall if result in blocks the same colors as the undelayed VID7 is high (S4). VID7M toggles at all other HIRES40 colors, 0101 patterns are violet in even points in HIRES40 processing(Tl, T2, and T3). locations and green in odd locations, 1010 patterns The fact that VID7M does not fall after PHASE are green in even locations tions, and 1111 patterns are and white.violet in odd loca- 1 • Q3' • AX' when VID7 is high creates a 14M period delay in processing for the 7-dot HIRES To select the 7 MHz LORES mode, select LORES- pattern present on VID6— VIDO. This is why 40 GRAPHICS and bring AN3 low (assumes 64K setting bit 7 of a stored HIRES pattern results RAM card installed). This mode will also be selected in blue or orange coloring instead of violet or if you bring up a LORES40 display and press and green in SINGLE-RES processing. hold CONTROL-RESET. This brings RESET' low 7. VID7M is forced to fall after PHASE 1 • AX' • which LORES brings AN3 low to force 7 MHz processing of patterns. Q3' when processing the first blanked video cycle at the right side of the screen (S5). This, along with undelayed LDPS', cuts off the far It is very interesting that you can inhibit HIRES- right delayed dot on the HIRES40 screen. 40 delay processing by bringing AN3 low. This pro- vides a means of changing the color of the entire Video Generation 8-23 a % s O) S2 8-24 Understanding the Apple He Table 8.9 VID7M and LDPS' Timing HAL Logic Equations. NOTES SIGNAL EQUATIONS VID7M LORES GRAPHICS IS HIGH SPEED S1-GR"»SEGB DOUBLE RES IS HIGH SPEED 52 = GR'.80COL" SAME AS 7M IF NOT HIRES 53 = GR'.7M FRCTXT" • 80COL 7M. UNDELAYED HIRES DELAY CHECK AT *1 • Q3' • AX' 54 = VID7'»*1»Q;^' NO DELAY AT RIGHT DISPLAY EDGE 55 = H0'-CLRREF Tl- VID7M»AX 1 • Q3' TOGGLE THROUGH AX T2 = VID7M«*0 .AX' KEEP TOGGLING THROUGH *0 T8 = VID7M-Q3 KEEP TOGGLING THROUGH Q3 DOUBLE RES CAUSES DOUBLE LDPS' S1=QS'.AX'.80C()L".GR' TEXT MODE LDPS' S2 = Q;V . AX' • *1 • GR' X' ALORES R3 = Q3' . AX' • •I'l • SEGB NOT DELAYED HIRES 54 = Q3'«AX'«*1»VID7' RIGHT DISPLAY EDGE CUTOFF 55 = Q;r . AX' • *1 • CLR REF • HO' 56 = Q:}' • AX • RAS" • 'CI • VID7 • SE(;B' . GR" HIRES DELAYED LDPS' HIRES4() screen instantaneously, no small feat 40 variations of 'VID7M and LDPS'. Note the unde- when you f()tisider thai you normally would have to layed timing on the last video cycle in Figure 3.2, look up addresses and change 7-dot patterns one by even though VID7 is high. Note also the double one to elianj^re the color of a HIRES objeet. To utilize width LDPS' pulse, which occursonlyatthis forced this capability, store all HIRES patterns with D7 cutoff point. set. Then with 8()C0L reset and a 64K auxiliary RAM card installed (or a. jumper between pins 50 TEXT OUTPUT and 550(1 the auxiliary slot), you can switch between }f reen/violet and orange/blue coloring via AN3. As a Apple He TEXT output timing is very straight- corollary, you can instantly shift the position of a forward. The video scanner drives character code H1RES4() display left or right 1/560 the width of the from RAM to the video data bus where it address^ Apple display via AN3. the video ROM. SEGA, SEGB, and SEGC are equiv- Instantaneous switching of HIRES colors sug- alent to VA, VB, and VC, and these three address gests ause for the 7M LORES mode. You can create a display of LORES $5 and LORES $A blocks and inputs to the video ROM select among the eight 7-dot segments of the character indicated by the code on instantaneously switch the entire LORES screen between gray/gray and green/violet coloring. I the video data bus. One segment of a character pat- tern is thus output for each of the eight times a know Mom about you're thisracing one. to your desk to write home to character code is driven out of RAM. The video ROM text patterns are illustrated in Figure 8.8. The right side cutoff of HIRES40 delayed pat- Figure 8.7 shows the output of the seventh (out of terns referred to in item 7 above represents an improvement over the Apple II in which the right- eight) dot patterns of a NORMAL ampersand and most dot is cut off or not, depending on the MSB of an INVERSE ampersand to the first two character the first byte scanned during the following HBL. It positions at the left of the screen. At the far left side would be preferable if delayed patterns were not cut of Figure 8.7, H5 through HO of the video scanner off at the right side, but that would not have been are at 0 11000 meaning HBL has just gone low and particularly convenient to do in the Apple lie timing WNDW will go low on the next scanner clock (RAS hardware structure (they would have had to add a rising during PHASE 1). The video data bus con- chip). tains inconsequential data from HBL scanned Figure 3.2 illustrates the right side cutoff of a memory, and the PICTURE signal is blanked be- HIRES40 delayed pattern along with other HIRES- cause WNDW is high, causing a high level to be shifted continuously to PICTURE'. Video Generation 8-25 SB SC SD SE $F BASE] ASCIll SCO !■■■ 1^1 ■■■■^ ■■■.^ ■ S10 S20 S30 r $40 I■■■■ ! nan !"• ■!"• [■■».. K B i eABCDEFGHIJKLNHO i PQRSTJviWXYZCM^_ P 8123456789= j< = >? i i:?ABCDEFGHIJKLMNn P PQRSTUUNXYZCM'-^_ i "'abcdef ghi jklmno 4t-^| B pqrstuMuixyzC i I's^ ^ NOTES: Q] "Mouse text" replaces letters and charactersat ASCII = S4f)-$5F in the enhanced firmware video ROM (see Chapter 6, The Apple lie F'imiware Upfcrade). Figure 6 A Apple He Video ROM Text Patterns. fl-26 Understanding the Apple He terns in the video ROM and provide the necessary The first time LDPS' falls at the left side of Figure horizontal spacing between characters. 8.7, WNDW is still high, and the video ROM output The first time LDPS' falls after WNDW drops is still held high by the pull-up resistors. Conse- low marks the beginning of the display on the quently, ONES are loaded into the load/shift regis- screen. This is also true of left side video output of ter and the PICTURE signal remains blank until LORES, HIRES undelayed, and HIRES delayed LDPS' falls again. timing. Whatever the display mode, the left side At about the same time that WNDW falls, data blanking is extended until the first display pattern from the H5— HO = 0 1 1000 access to RAM is latched in the auxiliary card and motherboard video latches. is loaded. The auxiliary video data then becomes valid on the The 1010011 pattern is shifted to PICTURE', with one shift every 14M rising since VID7M is held video data bus about 20 nanoseconds after PHASE 0 rises. This data is not used unless 80COL is set, low during TEXT time with 80COL set. Mother- board video data becomes valid about 20 nano- causing LDPS' to fall near the end of PHASE 0. seconds after PHASE 0 falls, while the auxiliary Assume for now that 80COL is set and that the Apple is in TEXT80 mode. This is the timing shown pattern is being shifted out. The video ROM then has at the bottom of Figure 8.7. about 390 nanoseconds to respond by making the The video bus now contains $A6, ASCII for a new pattern available for loading. NORMAL ampersand. The lOU translates VID7- In the Figure 8.7 example, the auxiliary data on 6 = 10 to RAIO— 9 = 10. so the processed video data the video data bus is now $26, code for an INVERSE bus input to the video ROM is also $A6. SEGC- ampersand. VID7— VID6 = 00 is translated in the SEGB-SEGA = 110 because this is the seventh of lOU to RAIO— RA9 = 00, so the GR-i-2, RAlO-9, eight segments, and GR+2 is low because TEXT VID5-0, SEGC-A video ROM address is 0,00, mode is selected. The video ROM address is there- 100110.110. At this location, the video ROM con- fore GR-^2. RAlO-9, VID5-0. SEGC-A = 0,10, tains 00101100, the dot pattern of the seventh of 1001 10.1 10. At this address, the video ROM contains eight segments of an INVERSE ampersand, and 11010011, the inverted pattern of the seventh seg- the complement of the pattern generated by the ment of a NORMAL ampersand.* NORMAL ampersand. The 00101100 pattern is About 390 nanoseconds after the auxiliary video loaded when LDPS' falls near the end of PHASE 1, data becomes valid on the video data bus, 14M rises and the resulting 7-dot pattern, 0101100, is shifted with LDPS' and VID7M low, loading the dot pat- to the PICTURE' line, LSB first. tern to the load/shift register. The access time of the The code for the NORMAL and INVERSE amper- video ROM in the Apple He must therefore be under sand in the DOUBLE-RES example are stored at 390 nanoseconds. One would think that this would the same address with the NORMAL code stored in dictate the use of a 350-nanosecond video ROM, but auxiliary card RAM and the INVERSE code stored don't bet on it. The Apple II requires the same 390- in motherboard RAM. This is an essential feature of nanosecond access time for its text ROM, and 450- all Apple lie DOUBLE-RES processing— two video nanosecond text ROMs are used in the Apple II. I cycles per video scanner state. On the other hand, don't know if they decided to use a 350 nanosecond SINGLE-RES processing consistsof one video cycle video ROM in the Apple lie because the ROM is only pervideoscannerstate. This is implemented simply labeled with Apple's part number, not the more by loading video patterns only once per scanner descriptive manufacturer's part number. In any state (when motherboard data is on the video bus) case I recommend using a 350-nanosecond part if and shifting the pattern every other 14M rising(one you decide to install a custom video EPROM in your half as fast as DOUBLE-RES shifting). Apple lie. The NORMAL and INVERSE ampersand code The 11010011 pattern represents only seven dot in the SINGLE-RES example are stored inadjacent positions because only six shifts will take place locations of motherboard RAM (H5— 0 = 011000 and before the next pattern is loaded. Only 1010011 will 011001). LDPS' doesn't fall during PHASE 0, and be shifted out, LSB first. The leading and trailing the pattern resulting from auxiliary video data is ONEs are present on all of the NORMAL text pat- thus ignored. The blanking period at the leftside is *The pattern is inverted here because the QH outputof the load/ extended ^ microsecond beyond that of DOUBLE- shift register is connected to the PICTURE' line which is RES processing, until the pattern resulting from inverted and ORed with ALTVID' to produce the PICTURE motherboard data is loaded. The patterns loaded are sigrnal. Therefore, all patterns in the video ROM are inverted (ONE = black; ZERO = white). identical to those of the DOUBLE-RES example, a NORMAL ampersand followed by an INVERSE Video Generation 8-27 ampersand. Only the processing speed and conse- into four areas to implement certain details of quent character horizontal size are different LORES processing. Notice the long delay, in Figure 8,7, between a The contents of the LORES areaofthe video ROM video scanner state and the LDPS' which loads pat- are inverted double patterns, generated from VID3— terns resulting from code stored at a RAM location VIDO or VID7— VID4 depending on VC; rotated or addressed by that video scanner state. This is why not rotated two bits depending on HO. The VC varia- WNDW and SEGA— SEGC are delayed by one tion results in VID3— 0 being processed as the upper scanner clock. Because of the delay, WNDW' stays block pattern and VID7— 4 being processed as the high long enough that blanking ONEs are loaded lower block pattern. The HO variation causes a and shifted until the time a displayed dot pattern is stored pattern to generate the same color whether it ready to be loaded and shifted out. Also, the delay is stored in an even or odd RAM location. causes SEGA— SEGC to address the video ROM Table 8.10 shows the outputs of the video ROM simultaneously with video data resulting from the corresponding to the stored byte, $27, as an example video scanner state which produced SEGA— SEGC. of the VC/HO variations. When VC is low, LORES upper blocks are displayed and the lower four bits LORES GRAPHICS OUTPUT (0111) generate the pattern to be shifted. In even LORES blocks are not generated the way you processing (as identified by HO'), the simple inver- sion of the 01 11 pattern (1000) isoutput in the upper would expect from lookingat a television. You would four bits and lower four bits of the video ROM. expect big 1-microsecond pulses on the PICTURE Rotating this 8-bit double pattern is the same as signal would be required to produce those big one rotatingthe4-bit pattern, so even processingof 0111 microsecond wide blocks. In reality, the only pulses consists of rotating 1000. that areone microsecond wide in LORES are white When 0111 is driven from an odd RAM addre.ss, blocks. The colored blocks are made up of a stri ng of 0010 0010 is produced at the video ROM output. narrow pulses, too narrow for a television to paint 0010 0010 is 1000 1000 rotated two bits (right or without blurring them into blocks, and narrow left— the result is the same). This rotation offset enough that they will be passed by the television's compensates for the fact that there are 3.5 cycles of chrominance amplifier. COLOR REFERENCE in a SINGLE-RES video The LORES colored PICTURE signal swings cycle. With a pattern pre-rotated by two dot widths, back and forth between the black and white levels at a LORES pattern is generated in a constant phase 3.58 MHz. Color variations result from variations in relationship with COLOR REFERENCE, whether the phase relationship between the PICTURE sig- it is stored in an even or an odd RAM location. nal and COLOR REFERENCE. Also, the LORES Table 8.10 also shows the lower block processing 3.58 MHz PICTURE signal may or may not be of the $27 example. This is identical to the upper symmetrical, and this adds greater variety to the block processing, except that 0010 is used to produce available colors. All told, there are 12 LORES pat- the even inverted pattern 1101 1101 or the odd terns which produce colored signals: 0001, 0010, i nverted and rotated pattern 0 11 1 0 1 1 1 at the output 0011,0100,0110, 0111, 1000, 1001, 1011, 1100, 1101, of the video ROM. and 1110. Figure 8.9 (color section) shows several timing The GR+2, RAlO-9, VID5-0, SEGC, SEGB, SEGA address to the video ROM in LORES examples of LORES blocks— three in SINGLE- RES and two in DOUBLE-RES, These examples GRAPHICS mode is equivalent to 1, VID7—6, illustrate the nature of LORE S tim ing. The examples VID5-0, VC, 1, HO. GR+2 = 1 and SEGB = 1 shown could be VC or VC processing because there together identify the LORES GRAPHICS area of is no difference between VC' and VC once the double the video ROM. VC and HO divide the video ROM pattern is loaded in the load/shift register. Table 8.10 HO/VC Variations of LORES, ViD7-0 = $27. STORED PATTERNS VCHO VIDEO ROM OUTPUT $27(0010 0111) 0 0 $88 (1000 1000) $27(0010 0111) 0 1 $22 (0010 0010) $27(0010 0111) $DD(1101 1101) 1 0 1 1 $27(0010 0111) $77(0111 0111) -•*■%. 8-28 Underetanding the Apple He waves whose 3.58 MHz sinusoidal component is LORES40 Output passed by the television's chrominance amplifier to The first three examples in Figure 8.9 show produce different colors. The asymmetrical square even/odd pairs of LORES40 blocks. This mode is waves are produced by patterns with only one bit set selected by resetting 80COL, TEXT, and HIRES or only one bit reset. Those with only one bit set and setting AN3 (FRCTXT')-* Gated GR+2' high produce dark colors, because the PICTURE signal and SEGB {LORES) forces VID7M low, so all spends most of its time in the black. Conversely, the LORES pattern circulation is at 14 MHz. LDPS' patterns with only one bit reset produce bright falls only during PHASE Lsoonly the motherboard colors. As the example shows, the picture pattern at double pattern is loaded. The double pattern is the border between colors 0111 and 1000 is a combi- shifted out 1.75 times (14 cycles/S bits) before the nation ofthe two separate patterns. Even GUI fol- next double pattern is loaded, so the 4-dot patterns lowed by odd 1000 produces a violet border. are effectively shifted out 3.5 times to generate the The light blue block shows that some things are 1-microsecond LORES block width, The 4-dot pat- predictable about bordering colors in LORES terns are therefore output at 3.5 mil lion patterns per blocks. Any odd pattern which ends in the white second, not coincidentally, the frequency of COLOR REFERENCE. As a result, all LORES patterns level will combine with the left side of even 0111 to form a white border. The bright colors are particu- except 0000, 0101, 1010, and 1111 cause the PIC- TURE signal to alternate at the COLOR REFER- larly prone to forming white borders, because they're ENCE frequency and produce colored blocks on the only one black period away from being white television screen. themselves. The first example of Figure 8.9 shows the output The third example in Figure 8.9 is even 0101 fol- produced by 1001 stored in an adjacent even/odd lowed byodd 1010. These are the two gray LORES pair of memory locations. In the even cycle, 0110 patterns. They are gray, because the PICTURE 0110 is loaded to the load/shift register, rotated to signal they produce is 7 MHz, which will not be the PICTURE' line beginning with the LSB, and passed by the television's chrominance amplifier. inverted and applied to the PICTURE signal Now gray is really white in a dark disguise. White (10011001100110). In the odd cycle, 1001 1001 is lightcancomein many intensities as evidenced by a loaded and rotated to the PICTURE signal with black and white television picture, and LORES inversion (01100110011001). In either an even or an patterns 0101 and 1010 are just less intense white. odd cycle, the PICTURE signal is a symmetrical They are equal to each other in intensity, and are square wave with the same relationship to COLOR therefore identical shades of gray. This is why the REFERENCE as HIRES orange. technical overview stated there were 15, not 16, The coloring of the left and right edge of a LORES LORES colors including black and white. block depends on the patternsof the adjacent blocks. Even though the two grays produce the same If adjacent blocks are the same pattern, the PIC- medium intensity colorless blocks, they are 180 TURE signal is continuous, meaning orange mates degrees out of phase with each other. Thus, when to orange with no off color fringe between the two 1010 follows 0101 there is a discontinuity in the blocks. Different colors mate together with a joining waveform at the border between them and a result- pattern which is not the same as either of the joining ing color fringe. This can be done on purpose to colors, creating a color fringe which is more or less separate two gray solids horizontally, or it can be prominent depending on the colors and whether avoided by using only 0101 or 1010 in a display. A theymeetatan odd-even or even-odd junction .Even good practice would be to choose one gray over the though the right and left side of the first Figure 8.9 other to minimize unpleasant fringe borders with example are colored orange, coloring here depends other colors. on the adjacent patterns. When the LORES colors are displayed side by The second example in Figure 8.9 is even 0111, side in numerical sequence, there is no apparent light blue, followed by odd 1000, dark brown. These color continuity between them. The fact is that they patterns produce asymmetrical 3.58 MHz square form a circular pattern of eight color tones deter- 'If FRCTXT' is brought low and 80COL is not set, VID7M will mined by the phase relationship to COLOR REF- alternate and the abnormal LORES mode described in the ERENCE. This is not apparent when they are in VIDEO GENERATION TIMING SIGNALS section will numerical sequence, because video processingtreats result. Detailed timing descriptions of the abnormal LORES the 4-bit color data as a dot pattern, not a numerical mode are not presented in this book. value. i, ,, Video Generation 8-29 Figure 8.10 shows tine PICTURE signals, com- only difference between LORES40 and LORES80 pared toCOLOR REFERENCE, which are pro- timing is that LDPS' falls during PHASE 0 in duced by the various LORES patterns. The colors LORES80 as well as during PHASE 1, so that the are shown in an order in which the picture pulse auxiliary pattern is loaded and shifted out in addi- shifts right as the colors progress from top to bot- tion to the motherboard pattern. The LORES80 tom. Avery interesting point becomes evident when patterns cut each other off after 6 shifts so 1.75 4-dot looking at this figure. There are four color tone patterns are output per .5 microsecond video cycle. pairs: dark and light nnagenta, dark and light blue, Since patterns are shifted at the same rate in dark and light blue-green, and dark and light LORES40 as they are in LORES80, the same colors brown. For example, the dark magenta pulse is sur- are available. In LORES80, however, the blocks are rounded equally on both sides by the light magenta only half as wide. Additionally, a pattern stored in pulse, and the horizontal center of both pulses is at auxiliary card RAM produces a different color than the same point on the COLOR REFERENCE. As a the same pattern stored in motherboard RAM. This result, they produce the same color tone, but a series can be seen from the first LORES80 example of of wide pulses is brighter and whiter than the series Figure 8.9, which shows what happens when the of narrow pulses with the same color tone. 0010 pattern is stored continuously in auxiliary card Now color 0001 is usually referred to as magenta, and motherboard display memory. and color 1011 is usually referred to as pink. This When 0010 is driven out of an even auxiliary card book has been calling pink "light magenta" to make RAM location (left side Figure 8.9), 1101 1101 is the point that color 1011 looks like color 0001 with a loaded, shifted out LSB first, and inverted (0100 lot of whiteness in it. Anyone who wants to is 010). When this is followed by 0010 from an even encouraged to call pink "pink." motherboard RAM location, the identical 0100 010 Figure 8.11 (color section) is a photograph of the PICTURE signal results, but this is not a continua- LORES colors based on their circular nature. This tion ofthe4-dotauxiliary PICTURE signal where it display was generated by constructing the LORES was cut off. The result is that the color for the period colors in HIRES80 mode. As is obvious from this spanning these two video cycles is blurred and photo, the same colors are available in HIRES80 unpleasant. This discontinuity exists throughout that are available in LORES. HIRES80 was chosen the example. to illustrate the circular nature of these colors The PICTURE signal required to continueaOlOO because circles look better in HIRES than in LORES. 010 chain is 0 0100 01. This chain is produced by In this display, the different color tones are in 0100 stored in a motherboard RAM location, and the different sectors of a circle and brightness is repre- final example of Figure 8.9 shows that 0010 stored sented radially in the circle with dark at the center continuously in auxiliary card RAM combined with and white at the outside. Black, gray, and white 0100 stored continuously in motherboard RAM pro- cover ail sectors of the circle, because they have no duces acontinuousdiaplay the same color as LORES- coloring. Black is the darkest color. Then comes 40 pattern 0100. A correlation exists here that can 0001, 0010, 0100, and 1000. The grays, 0101 and be extended to all the LORES patterns. To repro- 1010, are the same brightness as the HIRES equiv- duce a motherboard color, store the motherboard alents, 0011, 0110, 1100, and 1001. Next brightest color, rotated right one bit, in auxiliary card RAM. are 0111, 1110, 1101, and 1011. Brightest of all is Table 8.11 illustrates this correlation for all the white. Looking at the colors in this way should give LORES patterns. you insights when you are trying to produce pleas- One shortcom ing of LORES80 graph ics is that the ing LORES or HIRES80 displays. horizontal block size variation is greater than that of L0RES40. Variation occurs in the size of a single block depending how much black space there is at LORESaO Output the left and right side of the block. This variation The last two examples in Figure 8.9 show the becomes more pronounced with colors with fewer outputof f ive adjacent LORES80 blocks. This mode dots set, and it becomes particularly pronounced in is selected by resetting TEXT, HIRES, and AN3 LORES80 because the maximum block size is only (FRCTXT') and setting 80COL. This causes no seven dot widths instead of 14. As an extreme ex- change in speed of pattern shifting from LORES40. ample, even 1000 or odd 0010 will cause the display LORES40 shifting is already at 14 MHz, and nothing of blocks only one dot wide in LORES80 GRAPH- happens faster than 14 MHz in an Apple He. The ICS mode. ^ 8-30 Understanding the ya ^ple lie COLO R REFERENCE - r L 0001 DARK MAGENTA J J 1011 LIGHT MAGENTA 0011 HIRES40 VIOLET J r 0010 DARK BLUE 0111 LIGHT BLUE 0110 HIRES40 BLUE en] 0100 DARKBLUE-GRE EN 1110 LIGHT BLUE-GRE L 1100 HtRES40 GREEN 1 L 1000 DARK BROWN 1 L 1101 LIGHT BROWN 1001 HIRES40 ORANGE 0101 $5 GRAY J 1 1 1010 S10 GRAY 1 1 L -«). 1111 WHITE 0000 BLACK Figu ree.10 -6)Coi to CO LORREF LORE5/HIR ES80 Patten npareti «ENCI E(a 1SCC5- ''ai£4iiu-Fr- ""^ I- Video Generation 8-31 Table 8.1 iAuxMtary Card/Motherboard LORES Color Equrvolents. SINGLE RES COLOR AUXILIARY CARD MOTHERBOARD $0 mm) $0 (ftOOO) $0 (0000) $1 (t)OOl) $«(im)0) $1 (0001) !52(f)OK)) $1 (00(»1) $2 (0010) $.s(0()n> $90001) $2(0010) $3(0011) $4 (0100) . $4 (01 Oft) $5(0101) $A (1010) $5(0101) $6(0110) $r^(oon) $fi(01I0) $7(0111) $B(ion) $7(0111) $8(1000) $4(0100) $K(1000) $9(1001) $C(1100) $9(1001) $A (1010) $5(0101) $A(1010) $B(]011) $0(1101) IRdOll) $c{noo) $fi(0110) $(;(n()0) $D(1U)1) $E(1110) $D(1101) $E(1110) $7(0111) $E(1110) $F(1111) IFOlll) $F(1111) LORES80 plotting is not supported by Apple lie thing but simple. Figure 8.13 (color section) shows a firmware. However, it is not a difficult matter to number of color variations of the single dot pattern, write Applesoft or I nteger B A S IC subrouti nes w hich 1011010. As these examples are discussed, it will be utilize the LORES80 mode to generate 80 x 48 seen that HIRES coloration varies with single or LORES block displays. Figure 8.12 (color section) is double resolution, even or odd RAM location of the such a display, created by the Applesoft program of dot pattern, auxiliary or motherboard RAM loca- Figure 8,20 in an application note at the back of this tion (HIRES80), delayed or undelayed timing of the chapter. As Figure 8.12 shows, LORES80 plotting displayed pattern (HIRES40), and delayed or unde- gives very reasonable resolution considering the layed timing of the adjacent displayed pattern speed with which a display can be updated. (HIRES40). The GR+2, RAlO-9. VID5-0, SEGC, SEGB, HIRES GRAPHICS OUTPUT SEGA address to the video ROM in HIRES GRAPH- ICS mode is equivalent to 1,VID7~6,VID5-0,VC, HIRES output has similarities to TEXT output. 0, HO. GR+2 = 1 and SEGB = 0 together identify the Both the HIRES and TEXT PICTURE signals are HIRES GRAPHICS area of the video ROM. The generated by shifting out 7-bit dot patterns. For this VID7, VC, and HO address inputs do nothing but reason, it is possible to draw text using HIRES divide the ROM into eight identical areas. These graphics with the same 7 x 8 dot patterns generated addressing inputs affect LORES patterns, not by the video ROM, .The HIRES TEXT will have HIRES patterns. In other words, the HIRES coloring however, because the COLOR BURST is GRAPHICS video ROM address is effectively enabled. Besides the COLOR BURST, important VID6-VID0. differences are: The contentsof the HIRES areaof the video ROM 1. HIRES patterns are stored directly in RAM, is an inverted mapoftheVID6—VID0 address with seven dots per byte. TEXT ASCII is stored in the extraneous MSB set in all locations.* By this it is RAM. one character per byte, and TEXT pat- meant that the contents of VID6— 0 = 0000000 is terns are stored in the video ROM, eight rows of lllUlll, the contents of VID6-0 = 0000001 is seven dots per ASCII code. 111 lino, etc. As a result, the net effect of the video ROM in HIRES GRAPHICS is to invert 2. HIRES40 7-dot patterns are delayed by one 14M period if the MSB (VID7) of the memory the dot pattern on VID6— VIDO, The display map pattern in all of the examples of Figure 8.13 is representation is high. of the pattern is set and FRCTXT' 1011010, which produces the pattern 10100101 at the output of the video ROM, While HIRES dot generation is a simple transla- ♦The M SB of ttie pattern from the video ROM is never shifted out tion ofdot patterns stored in memory to dot patterns in HIRES GRAPHICS, so it is extraneous. Apple had to put on the screen, the coloring of the patterns is any- something in there, and chose to nnake it a ONE. ^ m 8^32 Understanding the Apple lie COLOR REFERENCE. HIRES green and HIRES HIRES40 Output violet complement each other; that is, they are 180 The top two examplesof Figure 8.13show the four degrees out of phase. basic phase relationships between The HrRES40 pat- When the identical 1011010 pattern is driven terns and COLOR REFERENCE. result is the from an odd address to cause loading and shiftintrof same picture pattern colored four different ways. 0100101 .the PICTURE signal swings from white to The four different colorings are produced by storing black and back just as it did when the pattern was the pattern 1011010 at adjacent memory locations loaded from an even address. The COLOR REF- with D7 reset and at adjacent memory locations ERENCE, however, is 180 degrees out of phase with D7 set. from the way itwasduring the adjacentvideo cycle. The top HIRES pattern in Figure 8.13 is formed The coloring of the screen dots is therefore the com- by 01011010 being driven out of RAM by scanner plement ofthe color of the pattern output in the access to an even address followed by an odd adjacent video cycle. Green becomes violet, violet address. Because the MSB is reset, the inverted becomes green, and white remains white. (0100101) pattern will be loaded and shifted out The nature of HIRES40 green and violet video undelayed. To determine whether timing is to be delayed or should now be fairly clear. The HIRES40 dot is undelayed for a HIRES pattern, VID7 is monitored exactly the width of half of a COLOR REFER- ENCE period. Visualize the COLOR REFERENCE at PHASE 1 • AX' • Q3' (marked with a dot in Figure 8.13) in the timing HAL. If VID7 is low at alternating up and down as the beam crosses the this point, as in the first example of Figure 8.13, screen, starti ng with COLOR REFERENCE low as LDPS' and VID7M both fall on the following 14M the display begins. If even position dots are turned rising. VID7M toggles on 14M rising at all other on, they coincide with a quarter cycle of COLOR times, so undelayed VID7M is identical to 7M. The REFERENCE low followed by a quarter cycle of net result is that undelayed HIRES40 loading and COLOR REFERENCE high, and are violet. Odd shifting is identical toTEXT40 loading and shifting. dots are in the opposite phase relationship with As the leading 101 is shifted out in the top ex- COLOR REFERENCE and are green, and two or ample of Figure 8.13, the PICTURE signal starts more adjacent dots are white. black, swings white, then swings black, creating a Manyof the HIRES displays yousee on theApple square wave identical in frequency to the COLOR lie are made up of SINGLE-RES undelayed pat- REFERENCE, 3.58 MHz. The television will pass terns. In fact, these were the only HIRES patterns this signal through its chrominance amplifier and that were available in the original Revision 0 Apple phase compare it to the COLOR REFERENCE II. The undelayed HIRES40 mode gives you 280 which it has reconstructed from the COLOR BURST. programmable dots per scan with violet, green, or The result of this phase comparison will be color white coloring. If color is ignored, its resolution is signals resulting in a HIRES green coloring of the 280 X 192 points, but if green or violet coloring is dot on the screen. Compare the green dot position to desired, only half of the horizontal dot positions can the COLOR REFERENCE. Any PICTURE signal be used and the overall resolution is 140 x 192 points. which goes white then black in this relationship The output of the same 1011010 dot pattern, with the COLOR REFERENCE will produce green stored at adjacent memory locations with D7 set is coloring on the television. shown in the second example of Figure 8.13. The Shifting along, we come to the two adjacent white picture pattern is the same, but it is delayed by one dots. These dots are produced by a signal that goes 14M period since VID7 is sampled high at PHASE 1 white then black at 1.79 MHz, one half of the fre- • AX' • Q3'. With continuous delayed patterns as quency ofthe COLOR REFERENCE. Very little of this signal can get through the television chromi- illustrated in this example, LDPS' is low during the last 14M period of PHASE 1 and VID7M is equiva- nance amplifier. The result is absence of color sig- lent to 7M' {as opposed to equivalence with 7M). nals and subsequent white illumination. Anywhere Since the identical pattern is delayed by one 14M on the screen, COLOR BURST or no COLOR period from the previous example, a new pair of BURST, bringing the PICTURE signal to the white level for a full period of COLOR REFERENCE will complementary colors, orange and blue, are pro- duced. The new colors are a result of the fact that result in a white picture. The white pulse is followed by a violet pulse, iden- delayed dots have a different phase relationship with COLOR REFERENCE than undelayed dots. tical inpulse width to the green pulse but occurring in opposite phase relationship when compared to Along with the color change, the delayed pattern is shifted to the rightone half of a HIRES40 dot width. ;*-a Video Generation 8-33 Delaying the 7-dot patterns is a tricky way of remove the delay from the PICTURE signal of the sprucing up the HIRES40 display (violet and green second example so that it is identical to the PIC- get a little old). Programming HIRES40 video TURE signal of the first example. Orange is thus becomes even more of an abstract art, however, with instantly changed to green, blue is changed to violet, each group of seven dots having a color and position and all delayed dots are shifted left 1/560 the width characteristic. Add this to the facts that alternating of the screen display. dot positions produce different colors, screen memory Why do colored HIRES40 objects appear solid if addresses are difficult to compute, and delayed every other dot is turned off? Shouldn't a violet HIRES patterns interfere with adjacent undelayed object appear to be numerous horizontal rowsof dots HIRES patterns; and you've got real programming rather than solid lines? The object appears solid complexity. vertically because the horizontal scans are so close Delayed and undelayed HIRES patterns inter- together. If you look at the violetobjeetup close, you fere with each other? They sure do, but before we' get will see that it appears to be numerous horizontal into that, let's summarize the characteristics of lines. The reason that the object appears solid hori- HIRES40 video based on the discussion to this point. zontal y isthat a multichannel color television is not First, there are 192 horizontal rows of dots. In each capable of turning its beam intensity on and off row, 280 dots (40 x 7) may be turned on or off, but cleanly at 3.58 MHz. Instead, the dots are blurred since each group of seven dots may be shifted right into continuous horizontal lines. For the same rea- half of a dot width, there are 560 dot positions in a son, Apple text issomewhat blurred when displayed row. Color depends on position, and there are 140 on a television set. violet positions, 140 green positions, 140 blue posi- Now if you inject the same VIDEO signal into a tions, and 140 orange positions. Any two adjacent high frequency response video monitor, you will dotsturnedon will be white. We will see shortly that clearly see the black spots between the dots in the there are really only 139 orange positions. This is lines that were violet on the television. It is very because an orange dot on the far right of the screen educational to compare all forms of Apple video to will be cut off by WNDW to make it dark brown. simultaneous displays on a television and high fre- Also, two adjacent delayed dots at the far right will quency monitor. HIRES and LORES graphics be light blue-green, not white. modes use the "slowness" of a television to display If color isof no concern, there is uninhibited pro- colored solids, but the monitor shows the dot pat- gramming ofa 192 X 280 matrix of dots. With re- terns whichis produce the solids.that The are "slowness" strictions, this becomes 192 x 560. The main restric- television why computers designedof toa tion isthat a delayed dot cannot be in the same 7-bit output TEXT to a television have a display of 40 group as an undelayed dot. For example, you can TEXT characters or less. It is also for this reason draw aslanted straight line close to the vertical with that when you use the 80-column text display capa- 192 X 560 resolution. You can also draw a very nice bility of the Apple lie, you must support it with a vertically oriented parabola with 560-dot horizontal high frequency response video monitor. resolution at the portions where the slope is more vertical. The other restriction on 560-dot resolution Interference Between Adjacent Delayed is the interference at the boundary between adja- and Undelayed HIRES40 Patterns cent delayed and undelayed patterns which will be The 7-dot, HIRES40 patterns fit snugly together detailed shortly. if the adjacent patterns are all delayed or unde- For coherent violet, green, blue, and orange layed, but problems can be caused when they are colored displays, there is 192 x 140 dot resolution as mixed together. This can be seen from the third long as certain pairs of colors don't get too close to example of Figure 8.13 which shows the processing each other. Anytime you plot agreen dot in thesame of the same 1011010 pattern stored in adjacent loca- 7-dot pattern as an orange dot, that orange dot turns tions with D7 set in the even locations and reset in to green, because D7 had to be reset in that memory the odd locations. location to plot the green dot. Similar considerations An undelayed video shift-cycle is just being com- exist for mixing blue and violet. Any two adjacent pleted at the far left of example 3, so VID7M is dots will always be white, initially in phase with 7M. Then a delayed cycle is ; Aswasmentioned in the VIDEO GENERATION initiated by the fact that VID7 is high at PHASE 1 • TIMING SIGNALS section, delayed timing is inhib- AX' • Q3'. This delays LDPS' and VID7M so that the ' ited when FRCTXT' is low. The effect of pulling next pattern is delayed— but think what it does to : FRCTXT' low ($C05E) in Figure 8.13 would be to the present pattern. Since the loading of the new t-34 Understanding the Apple lie produced at even/odd memory addressing borders pattern is delayed, the last dot of the previous cycle Colors D and 8 can be produced at odd/even borders is extended by half of a dot width. In other words, a Colors B and E can be produced at odd/even or delayed HIRES40 pattern extends the trailing even/odd borders. LORES color E can also be pro- dot or black space of a preceding u ndelayed pat- duced at the far rightof the HIRES screen. Finally tern by half of a dot width. Note that VID7 is sampled for delayed timing orange HIRES dots at the right side of the screen only during PHASE 1, not during PHASE 0. This is are LORES dark brown (8).* Figure 8.15 shows some patterns created by mix- because the HIRES delay only can occur in HIRES- 40, not HIRES80 mode. The auxiliary card data is ing delayed and undelayed dot patterns. Compari- on the video data bus during PHASE 0, and this is son to Figure 8.10 in the preceding LORES section will show that these patterns have the same phase not used in SINGLE-RES modes. Only the mother- board data on VID7 of the video data bus during relationship with COLOR REFERENCE as var- ious LORES colors. The exception is the case where PHASE 1 is sampled to determine delayed or unde- layed timing. a trailing 1-0 delayed pattern is cut off by an unde- The delayed pattern is shifted out until the deci- layed 1-0 pattern . This creates green or violet with a sion point for delayed or undelayed timing on the different shade than any HIRES40or LORES color. folloviring cycle is reached. VID7 is reset novi', indi- The general rule of all of these HIRES40 interfer- cating that the following pattern is undelayed. Con- ence patterns is that delayed extends undelayed, sequently, the timing HAL holds VID7M low and and undelayed cuts off delayed. Interference borders can be used to display iso- drops LDPS' on the next cycle to cause undelayed timing. The new pattern, however, is loaded when lated dots or vertical line segments in HIRES40 the last dot of the delayed pattern has only con- mode that are not one of the four HIRES40 colors. trolled the PICTURE' line for half of the normal Mostly, though, interference borders are a nuisance. period. In other words, an undelayed HIRES pat- Anytime two different colors get close to each other tern cuts off the trailing dot or black space of a horizontally, the video pattern at their border is precedingdelayed pattern to half of adot width. different than either of the solid colors when com- The point of all this is that continuous undelayed pared toCOLOR REFERENCE. Awareness of the or delayed patterns fit snugly together, but there is causes of off color fringes should help you experi- discontinuity between adjacent undelayed and de- ment with color combinations that produce eye layed patterns. Cutting off or extending a dot has pleasing displays. the effect of slightly changing the dot pattern and, The extreme left and right dot positions are spe- more noticeably, changingthecoloringof the border cial cases for delayed patterns. An undelayed pat- dots. As a result, the HIRES programmer has one tern at the far left may extend the previous undelayed more thing that affects color to educate himself pattern, but this extended pattern will be the final about and take into account. On the plus side, the blanked pattern of HBL. The result is that the programmer can draw vertical lines at pattern delayed pattern at the far left pulls the black mar- borders in eight colors that are not otherwise avail- gin to itself. able inHIRES40 mode. He does this simply by turn- A delayed pattern at the far right always has its ing on a right hand dot then extending or cutting it final dot position cut in half. This is because of the off via D7 of the following pattern. In some in- special logic in the timing HAL that always forces stances, nodots need be turned on in the following the first HBL pattern to undelayed, regardless of pattern. VID7. On the right side of the screen, the last Figure 8.14 (color section) is a photograph illus- delayed dot is in an orange dot position. This dot is trating the generation of LORES colors at borders cut off by HBL so the dot is dark brown rather than between delayed and undelayed 7-dot HIRES pat- orange, Similarly, a delayed white pair at the far terns. The program which generated this display is right is cut off to make it light blue-green. listed in Figure 3.11. The mixed LORES/HIRES display is created by switching screen modes in a The handling of right and left side delayed pat- terns represents an improvement of the Apple He 8515-cycle loop as is discussed in an application note over the Apple II, In the Apple II, delayed patterns in Chapter 3. As the photo shows, any LORES color on the left side can inadvertantly extend undis- except dark blue-green (4) and dark magenta (1) can played dots into the display, and the far right be produced at a limited number of screen positions. LORES colors 3, 6, C, and 9 are natural equivalents "The references to LORES color numbers here are valid for of the HIRE S40 colors. LORE S colors 7 and 2 can be LORES40 or LORES80 motherboard resident patterns- Auxil- iary card resident LORES80 patterns result in different colow; Video Generation 8^35 EVEN ODD ODD EVEN ■t COLOR REF COLOR REF J 01000000 lOOQOOOO 01000000 lOOOOOOO EXTEND VIOLET INTO EXTEND GREEN INTO LORES LIGHT BLUE (7) LORES LIGHT BROWN (D)_ 11000000 11000000 OOOOOOOO CUT OFF BLUE WITH BLACK TO OOOOOOOO CUT OFF ORANGE WITH BLACK TO PflODUCE LORES DARK BLUE (2) PRODUCE LORES DARK BROWN (81' 11000000 11000000 L 00000001 00000001 L CUT OFF BLUE WITH GREEN TO CUT OFF ORANGE WITH VIOLET TO PRODUCE LORES LIGHT BLUE-GREEN (E) PRODUCE LORES LIGHT MAGEMTA (Bl 1110000O OOOOOOOO 11100000 CUT OFF WHITE WITH CUT OFF WHITE WITH OOOOOOOO BLAC_K TO BLACK PRODUCE LORES F TO_PRO_OUCE BLACK TO PRODUCE LC LIGHT MAGENTA (B) LIGHT BLUE GREEN (El 10100000 10100000 000O0001 L L CUTOFFBLUE:BLACK LT CUTOFF0RANGE:BLACK 0OOO0O01 WITH GREEN TO PRODUCE WITH VIOLET TO PRODUCE BRIGHT GREEN BRIGHT VIOLET This is identical to Itie cut off of a defayed paltern by WNDW at the rigtil side o1 the screen Figure 8.15 Timing Diagram: HIRES40 Interference at Delayed/Undelayed Pattern Borders. delayed dot may or may not be cut off by undis- color video monitor, this has the effect of blurring played patterns. The Apple lie is far more predict- the pattern and creating some washed out unattrac- able, although it would have been nice if they had tive coloring. The 101 1010 pattern is blurred because figured out a way to eliminate the right side cutoff of it is too fine to display on a television. The colors delayed patterns without extending right side unde- aren't any good because there is no coherent rela- layed patterns. tionship with COLOR REFERENCE. The fact that the picture is compressed and still clearly visible on a high resolution monitor repre- HIRES60 Output sents the primary advantageofHIRESSO graphics. The final example of Figure 8.13 shows our weli Instead of the 280 x 192 resolution of HIRES40 used 1011010 pattern stored consecutively in auxil- mode, the programmer has complete on/off control iary and motherboard RAM with the Apple lie in ofa560x 192 matrix of dots. The improvement here HIRES80 mode. This mode is selected by resetting is obvious, and not many words will be wasted here TEXT and AN3 (FRCTXT') and setting HIRES on the advantages of 560-point monochrome resolu- and 80COL. Like double resolution TEXT, double tion over 280-point monochrome resolution. Rather, resolution HIRES is achieved by simply doubling many words will be wasted describing the less the speed of the load/shift cycle so that the aux il iary obvious color features of the HIRES80 displays. video data is loaded and shifted out, alternating A complete cycle of COLOR REFERENCE lasts with motherboard video data. The delayed timing is for two HIRES40 dot widths or four HIRES80 dot inhibited when FRCTXT' is low, so HIRES80LDPS' widths. As a result, alternating HIRES40 dots and VID7M timing is identical to that of TEXT80. exactly match the COLOR REFERENCE frequency The PICTURE signal resulting from HIRES80 and consequently produce coh erent colors. To ach ieve processing of the 1011010 pattern is identical to that coherent colors in HIRES80 processing, the dot pat- resulting from HIRES40 processing, except it is terns must be set up so that they recur at 3.58 MHz. compressed so that the dot position s are hal f as w ide. Storing the identical 7-dot pattern continuously as On a high resolution monochrome monitor, this has in Figure 8.13 cannot achieve this because the the effect of displaying the same patterns com- period of a seven dot video-cycle is not an integer pressed horizontally. On a television set or NTSC multiple of the 3.58 MHz period. ■ ■■■''-. ^. I;.i 8-36 Understanding the Apple lie shifted out, it will have coloration, although the Notice, in Figure 8.13, that a complete cycle of color of a single dot isolated in a field of black is hard COLOR REFERENCE lasts exactly four HIRES80 to discern, dot widths. This is the key to producing coherent A repeating 4-dot pattern is shifted L75 times in« color in HIRES80 displays. If any 4-dot pattern HIRES80 video cycle. To continue shifting the same other than 1 1 1 1 or 0000 is shifted continuously to the colored pattern in the next video cycle, the contents PICTURE' line, the PICTURE signal will alternate of the next scanned location of RAM must be the up and down at 3.58 MHz and produce coherent same as the current byte rotated left once. For color on the CRT. This is a burdensome program- example, if 0010 0010 is stored at an even auxiliary ming task to be sure, but the resulting high resolu- card location, its color can be matched by storing tion color displays can be very impressive. 0100 0100 in an even motherboard location, 1000 The colors available via continuous 4-dot HIRES 1000 in an odd auxiliary card location, or 0001 OflOl 80 patterns are the same colors that are available in in an odd motherboard location. Note that having LORES graphics (see Figures 8.10 and 8.11). In fact the MSB set in the 1000 1000 stored byte has no you can emulate LORES graphics from HIRES80 effect on the display. It is set here only because it mode by causing 4-dot patterns to be continuously makes it easy to visualize and compute the rotation shifted out for 14 dot widths (3.5 COLOR REFER- ENCE periods) in four adjacent horizontal scans. of 4-dot patterns. The LORES emulation mode would have the advan- The 4-dot patterns result in different colors tages that you could shift blocks vertically by V4 a depending on whether they are driven out of even or block height or horizontally by 1/14 a block width, odd auxiliary card or motherboard RAM locations, and that you could freely intermix emulated LORES When driven out of an even motherboard location, blocks with HIRES points and lines. The disadvan- the pattern will result in the same color as it would tage would be that considerably more computation in LORE S40 mode. The HIRES80 patterns required time and memory space would be required to main- to produce the various LORES colors are shown in tain the emulated LORES display. Table 8.12. With LORES graphics, you can shift any 4-dot There are any number of HIRES80 color plotting pattern to the PICTURE signal for 14 dot widths. methods that can be used by Apple He programs. With HIRES80 graphics, you can shift any 4-dot One method would be to utilize 560 x 192 plotting pattern for any number of dot widths you desire. If routines to selectively construct colored objects at you want to produce color blocks 8 dot widths by 2 various points on the screen. Another method would horizontal scans, you can do it. Even if only one dot is be to utilize super LORES routines which would Table 8 .1 2 HIRES80/ LORES Color Equivalents. EQUIVALENT HIRES80 PATTERNS LORES COLOR AUX/EVEN MBD/EVEN AUX/ODD MBD/ODD $0 (0000) $00 (0000 0000) $00 (0000 0000) $00 (0000 0000) $00 (0000 0000) $1 (0001) $88 (1000 0000) $11 (0001 0001) $22 (0010 0010) $44 (0100 0100) $2 (0010) $11 (0001 0001) $22(0010 0010) $44(0100 0100) $88 (1000 1000) $3(0011) $99 (1001 1001) $33(00110011) $66(0110 0110) $4 (0100) $22 (0010 0010) $44 (0100 0100) $88 (1000 1000) $CC (1100 1100) $5(0101) $AA (1010 1010) $55 (0101 0101) $AA (1010 1010) $11 (0001 0001) $6 (0110) $33(00110011) $66(0110 0110) $CC (1100 1100) $55 (0101 0101) $7(0111) $BB (1011 1011) $77(01110111) $EE (1110 1110) $99 (1001 1001) $8 (1000) $44 (0100 0100) $88 (1000 1000) $11 (0001 0001) $DD (1101 1101) $9(1001) $CC (1100 1100) $99 (1001 1001) $33(00110011) $22 (0010 0010) $A(1010) $55(01010101) SAA (1010 1010) $55(01010101) $66(0110 0110) $B(1011) $DD (1101 1101) $BB (1011 1011) $77(01110111) $AA (1010 1010) $C(1100) $66(0110 0110) $CC (1100 1100) $99(10011001) $EE (1110 1110) $D(1101) $EE (1110 1110) $DD (1101 1101) $BB (1011 1011) $33 (0011 0011) $E(1110) $77(01110111) $EE (1110 1110) $DD (1101 1101) $77 (0111 0111) $F(11U) $FF (1111 1111) $FF (1111 nil) $FF (11111111) $BB (1011 1011) $FF (1111 nil) Video Generation 8-37 plot a block of any height {1—192) and any width switch from 1111111 to 0000000, marking the (1—560) of any color (0—15) at any location (X,Y = beginning of HBL. At the same time the horizontal 0-659,0-191). section of the scanner goes to zeroes, the vertical A third method would be to utilize a 140 x 192 section goes to 110100000 making the term V4 • V2 colored HIRES mode with each 1/140 position con- true. This identifies TEXT time, but you can't sisting ofa blue (560 MOD 4 = 0), blue-green (560 immediately switch to TEXT processing because MOD 4 = 1), brown (560 MOD 4 - 2), and magenta the final displayed GRAPHICS pattern is not yet (560 MOD 4 = 3) dot. The color of each position is loaded in the load/shift register. For that matter, determined by which of its four dots is turned on. you can't start blanking yet either. The left side of Figure 8.16 (color section) shows What happens is that all GRAPHICS time switch- some sinewaves plotted in this format.* This method ing isdelayed by two scanner clocks (see GR, GR-H, provides true 140 x 192 resolution in 16 colors and GR-H2 in Figure 8.5). lOU outputs affected by (including black, white, 0101 gray and 1010 gray). this delay include SEGA, SEGB, RA9, RAIO, and Notice the jagged slopes of the sinewaves on the GRh-2. Because of the 2-clock delay, the timing HAL leftside of Figure 8. 16. These can be smoothed out to and video ROM are configured for GRAPHICS some extent on all colors except the 1-dot colors until the last video cycle on the right side of the (equivalents of LORES 1, 2, 4, and 8). The method screen is complete and blankingONEs are loaded in involves plotting 557 x 192 4-dot HIRES positions. the load/shift register. Here is the order of events for This takes more time and programming overhead Figure 8.17. than simple 140 x 192 plotting, but line smoothness approaches that of 560 x 192 resolution for the 3-dot 1. RAS'risesduring PHASE 1, bringing the video scanner to 110100000/0000000 after propaga- colors and white (see the sinewaves on the right side tion delay. V4 • V2 identifies TEXT time. of Figure 8.16), The smoothness of gray lines can be 2. At about the same time the video scanner further improved if use of 0101 gray and 1010 gray changes states, PHASE 0 rises, latching the is alternated every horizontal scan. The effective final GRAPHICS data in the motherboard video resolution of the 1-dot colors cannot be improved latch. because only 140 dots per horizontal scan can be displayed. 3. LDPS' falls during PHASE 0 of DOUBLE- RES modes, and the final auxiliary pattern is The HIRES80 color programming methods de- loaded and shifted out. scribed here are only ideas which seem very basic to me. These ideas could be expanded and mixed with 4. LDPS' falls during PHASE 1, loading the final motherboard pattern. In DOUBLE-RES or other ideas to provide some general purpose machine SINGLE-RES modes, this pattern will be the language HIRES plotting routines which support last one displayed before the right blanking all the graphics features of the Apple lie. This is margin. something that is very badly needed because only the HIRES40 features are supported by Apple He 5. RAS' rises during PHASE 1, followed by GR+1 ■firmware.** fall ing and WND W rising. GR-H selects TEXT related terms for SEGA-SEGC (VA, VB, and VC), but this change will not be felt at the MIXED MODE SWITCHING SEGA-SEGC lines until RAS' rises during PHASE 1 again. GRAPHICS time switching on A final topic to consider in video generation is SEGA-SEGC is thus delayed by two scanner MIXED mode switching. This is the reason we have clocks. GR+1 also disables HIRES time at the to live with those delayed GRAPHICS time terms lOU RAM addressing circuitry so the TEXT/ (GR+1 and GR-i-2), so we'll have a closer look. LORES area of scanned memory will now be , P'Kure8.17isatimingdiagramofthelastdispiay addressed. cycle of line 159 in MIXED mode. At the left side of this figure, HPE and H5— HO of the video scanner 6. At about the same time GR+1 falls, PHASE 0 rises to latch the first undisplayed video data. Figure 8.16 was produced by an Applesoft program {Figure This data will come from HIRES memory if H.21). An application note at the back of this chapter describes HIRES is set since HIRES TIME is just now falling. some Applesoft techniques for programm ing H IRE S80 displays. :**For alternate perspectives of HIRES80 operation and an 7. The final pattern is shifted out until LDPS' falls ^assembly language listing of some HIRES80 plotting routines, ■5ee TVue Sixteen-Color Hi-Res" by Allen Watson III, Apple again, loading the blanking ONEs resulting (Unkard. January, 1984. from WNDW high. 8^8 Understanding the Apple He \i to p gd Zl i o o on >- so p -IHL to P / uu i CO LU in 3 cc LU _J _J < o Lc; g^ x3 p 1- menl and presentation of comprehensive board memory. Hires plotting is a little more diffi- cult because on a scale of 0 to 559, pointsat 560 MOD machine language plotting utilities would be a size- 14 = 0 to 6 are plotted in auxiliary card memory, and able task, beyond the scope of UnderntiUKiing the A itpir llr. However, it is possible to write some very points at 560 MOD 14 = 7 to 13 are plotted in mother- simple Applesoft subroutines to plot .%() x 192 board memory (curse Apple for not including a 11 1 RIOS tMiints and 80 x 48 LORES blocks. Plotting MOD statement in Applesoft). Still, the 560 x 192 this way is slow, as you have probably guessed, but it HIRES plot subroutine (see lines 1000—1060 of is a fairly painless way of producing DOUBLE-RES Figure 8.21) is no big deal. ( ;RA I'll I<:S displays from Applesoft. Figure 8.21 is the program that produced the The basic technique is for a program to compute HIRES colored sine wavesof Figure 8.16. It is more the r>(;(l X 192 or 80 x 48 H,V coordinates, then call involved than the LORES example, but not because the plotting subroutine which develops the correct 560 X 192 plotting is more complex. To the contrary, hori/.ontal coordinate and plots the pointer block in 560 x 192 plotting is simpler than LORES 80 x 48 auxiliary card or motherboard memory using plotting because it is monochrome. The reason the III'LOT or F'LOT. It is ea.sy for the subroutine to HIRES program is more involved than the LORES choo.se motherboard or auxiliary card memory for program is that it demonstrates two differentmeth- plotting via I'A(iR2 with 80STORE set. ods of constructing 4-dot HIRES colors from the I''igure 8.20 is an example program which pro- 560-point monochrome subroutine. duced the LORES80 concentric circles of Figure 8.12. Initialization begins at line 100 and consists of The HIRES program plots sine waves at color, C, setting up LORES80 NOMIX mode and clearing equivalent to LORES colors 0-15. The subroutine the screen. Routines beginning at line 200 compute at line 2000 converts C to its binary equivalent in colors and 80 x 48 H,V coordinates of concentric C(3)-C(0). HIRES80 to LORES color equivalency circles and call the plot subroutine. The computa- issuch that 560MOD 4 = 0, 560 M0D4 = 1, 560 MOD 4 = 2, and 560 MOD 4 = 3 points are equivalent to tions are sin/cos manipulations with the H-coordi- nate scaled by a factor of 1.36 to compensate for C(l), C(2), C(3), and C(0) respectively of the binary Apple aspect ratio. The plot subroutine itself begins color word. For example, if HIRES80 points 0, 2, at line UXK). and 3 are turned on the resulting color will be equiv- 80STORE is set at the beginning of this program, alent toLORES color C(l), C(2)', 0(3). C(0) = 1011 = and it remains set throughout the program. Auxil- iary memory plotting can then be selected via In the first color construction method (see leftside PAGE2 (POKE AUX.O), and motherboard memory $B. Figure 8,16), there are 140 plotted horizontal of plotting can be selected by PAGE2' (POKE MBD.O). positions. The first position consists of dots J), 1. A The screen is cleared by calling the monitor and 3; the second position consists of dots 4, 5, 6, ano CLRSCR routine ($F832) after POKE AUX.O, then At each plotted position, the combi- 7: and so forth. again after POKE MBD.O. nation ofdots determined by 0(1), 0(2), 0(3), ana Odd horizontal blocks are plotted in motherboard 0(0) is turned on to produce a color equivalent w memory at H/2 in whatever color is selected by the LORES color C. For a given coordinate H,v, tne at program steps that plot these 4-dot positions are Video Generation 8-45 10 REM REM 20 WRES80 CONCENTRIC CIRCLES 30 REM REM 40 REM BY JIM SATHER 6/21/84 50 RE71 60 REM 100 REM INITIALIZE 70 110 REM 120 STR80 = - 16383:COL80 = - 16371:NOMIX » - 16302:MBD = - 16300 130 AUX = - 16299 :FRCTXT = - 16290 ilXLEER = - 1998 :CLR » 48 140 GR : POKE STR80,0: POKE NOMIX,0: POKE COL80,0: POKE FHCTXT,0 150 POKE AnX,0: CALL LCLEER: POKE MBD,0: CALL LCLEER: REM CLEAR SCREEN 200 REM 210 REM COLOR / CIRCLE COMPUTATIONS 220 REM 230 PTS =208: REM NUMBEE OF ANGLES SAMPLED 240 FOR ANGLE = 0 TO PTS - 1 250 Al = 6.2831852 * ANGLE / PTS:SI = SIN (Al) :C0 = COS (Al) 260 FOR C = 0 TO 7: COLOR= C: IF ANGLE > PTS / 2 THEN COLOR= C + 8 270 IF C = 0 THEN CCIX)R= 15 280 R = 24 - C * 3:V = 24 - SI * R:H = 40 + CO * R * 1.36: GOSUB 1010 290 NEXT C; NEXT ANGLE 300 GOTO 300 1000 REM 1010 REM PLOT H,V (H = 0-79, V = 0-47) 1020 REM 1030 H2 = INT (H) / 2 1040 IF H2 - INT {H2) THEN POKE HBD,0: PLOT H2,V: GOTO 1030 1050 POKE AOX,0:CSAV = PEEK (CLR) :C2 = CSAV / 2:C21 = C2 1060 IF C2 - C2% THEN C2% = C2% + 128 1070 POKE CLR,C2%: PLOT H2,V: POKE CLR,CSAV 1080 RETURN Figure 8^0 BASIC Listing: LORESfiO Concentric Circles. lines 370— 400. will result in clearing of the $2000-$3FFF area The second color construction method (see right withoutsettingor resetting PAGE2. This provides a side of Figure 8.16) supports 557 dot positions, each fast way of clearing the HIRES80 display (POKE four dot-widths wide. For color coherency, it must AUX.O : CALL HCLEER : POKE MBD.O : CALL be determined where the position starts in relation HCLEER). to COLOR REFERENCE. This is easy since we Of the two color construction methods, the 140 x begin with the information that position 0 starts 192 method is generally faster, but the 557 x 192 with a C(l) dot. For example, 379 MOD 4 = 3. so method yields higher resolution pictures with colors position 379 starts with a C(3) dot and consists of having more than one dot in the pattern. Either C(3),C(0),C(1), and C(2) dots in order. Plotting color method can be utilized to produce HIRES pictures $B at position 379 therefore consists of turning on in any LORES color. These routines, however, are dots 379, 380, and 381 ($B = 1011 = C(3), C(2)', C(l), useful only for experimentation, education, and C(0)), For a given coordinate H,V, the program plotting where Applesoft speed is sufficient. Faster steps that plot these 4-dot positions are at lines 550-590. DOUBLE-RES plotting requires machine language Lines 100-180 of Figure 8.21 initialize the Apple computation and plotting.* He HIRES80 display mode. Note that a short *See "True Sixt«en-Color Hi-Res" by Allen Watson III, Appli- f some machine language routine is poked into memory Orchard January 1984,foranassembly languafrelistmgo Miat loads $20 to the accumulator and jumps to HIRES80 plotting routines. The source code and some demon- to ♦P3EA (lines 150—170). Calling this short routine stration programs are available on diskette by sending $15 Cupertino , CA 95015. Apple Orchard, PO Box 6502, ' -""^1' Understanding the Apple He 10 REM 20 REM 30 REM HI RES 80 SINEWRVES 40 REM 50 REM BY JIM SATHER 6/21/84 60 REM 70 REM 100 REM INITIALIZE 110 REM 120 STR80 = - 163a3:COL80 = - 16371:NOMIX = - 16302:MBD = - 16300 130 AOX = - 16299:FRCTXT = - 16290:HCLEEH = 768 140 HGR : POKE STR80,0: POKE NOMIX,0: POKE COL80,B 145 POKE FSCTXT,0: fCO[iOR= 3 150 REM MOVE "LDA #$20, JMP SF3EA" TO fCLEER 160 POKE HCLEER,169: POKE HCLEER + 1,32: POKE HCLEER + 2,76 170 POKE HCLEER + 3,234: POKE HCLEER + 4,243 180 POKE A[JX,0: CALL HCLEER: REM CLEAR AUX 190 HPLOT 140,0 TO 140,26: HPLOT 140,167 TO 140,191: REM DRAW VERT LINE 200 POKE MBD,0: HPLOT 139,0 TO 139,26: HPLOT 139,167 TO 139,191 300 REM 310 REM GENERATE 140 X 192 SINEWAVES 'E 320 REM 330 FOR C = 1 TO 15:CLR = C: GOSUB 2000: REM FOR C0L0R=lTO15;GBr BINARY 340 FOR H0 = 0 TO 276 STEP 4: REM LEFT SCREEN; 1 OF 4 POINTS 350 FOR HPART = 0 TO 2: REM PLOT V FOR H, H+1.3, H+2.7 TO SMOOTH COT 360 V = 24.5 + C * 9 - 32 * SIN ((H0 + 1.333333 * HPART) * .0224399) 370 IF C(l) TOEN H = H0: OOSUB 1010: REM BLUE DOT + 1: GOSUB 1010: REM BLUE-GREEN DOT 380 IF C(2} THEN H = H0 + 2: GOSUB 1010: REM BROWN DOT 390 IF C(3) THEN H = H0 + 3: QOSOB 1010: REM MAGENTA DOT 400 IF C(0) THEN H = H0 410 NEXT HPART: NEXT H0 500 REM 510 REM GEMERAT 560 X 192 SINEWAVES 520 REM 530 REM SIN (2*PI*H/280) ; RIGHT SIDE 540 FOR H0 = 280 TO 556:V = 24.5 + C * 9 - 32 * SIN {H0 * .0224399) 550 PRT4% = (H0 / 4 - INT {H0 / 4) ) * 4 + .5: REM PRT4% = H0 MOD 4 560 IF PRT4% = 0 AND C(l) OR PBT4%. = 1 AND 0(2) OR PET4% = 2 AND C{3) OR PRT4% = 3 AND C(0) THEN H = H0: GOSUB 1010: REM PLOT POSITION+0 570 IF PRT4% = 0 AND C(2) OR PKT4% = 1 AND C(3) OR PBT4% = 2 AhD 0(0) OR PRT4% = 3 AND C(l) THEN H = H0 + 1: GOSUB 1010: REM PLOT POSITION+1 580 IF PRT4% - 0 AND C(3) OR PET4% = 1 AND C(0) OR PRT4% = 2 AND C(l) OR PRT4% = 3 AND C(2) THEN H = H0 + 2: GOSUB 1010: REM PLOT POSITION+2 590 IF PRr4% = 0 AND C(0) OR PBT4% = 1 AND C(l) OR PRT4% = 2 AND C('2) OR PRT4% = 3 AND C(3) THEN H = H0 + 3: GOSUB 1010: REM PLOT POSITION+3 600 NEXT H0: NEXT C: END 1000 REM 1010 REM PLOT H,V (H = 0-559, V = 0-191) 1020 REM 1030 M0O14 = INT (H) / 14:MCD14% = M0D14 1035 PART14% = 14 * (M0D14 - M0D14%) + .5 1040 POKE AOX,0: IF PART14% > 6 THEN POKE MBD,0:PART14% = PABT14% - 7 1050 HPLOT M0D14% * 7 + PABT14%,V 1060 RETURN 2000 REM 2010 REM CONVEiW CLR FROM DECIMAL TO HEX 2020 REM 2030 CLR% = CLR: FOR A = 0 TO 3 2040 C(A) = 1:CLR = CLFI / 2:CLRI = CLR% / 2 2045 IF CLR = CLR% THEN C(A) =0 2050 NEXT : RETURN Flgui«821 BASIC Listing: HIRES80 Sine WavM. Video Generation 8-47 TECHNICAL NOTE DETAILS OF TELEVISION PROCESSING OF APPLE VIDEO A rigorous examination of the television process- passed by the chrominance amplifier to the syn- ing of the Apple signal involves technical details chronous demodulator, where it is processed with beyond the scope of Understanding the Apple lie. the reconstructed COLOR REFERENCE sine and Brief descriptions of some of these technical details cosine waves to produce color signals. It is also pro- are presented here for those readers who wish to cessed by the luminance amplifier to produce the study television processing of Apple He video in luminance signal. depth, Many televisions have a 3.58 MHz trap in the A square wave is the sum of the odd harmon ics of a luminance path which reduces color interference sine wave of the same frequency. For example, a 3 with the luminance signal. The effect of this trap is MHz square wave can be produced by summing the to remove the 3.58 MHz variation, and pass a gray following sine waves: luminance level which lasts for the duration of the 3 MHz at amplitude A 3.58 MHz presence. A similar effect is felt on the 7 9 MHz at amplitude A/3 MHz modulation envelope produced by LORES/ 15 MHz at amplitude A/5 HIRES80 5 and 10 colors. The 7 MHz + carrier frequency is out of the band pass of the IF strip, so the 7 MHz variations are removed and replaced by a gray level. These solid gray levels do not degrade the Apple luminance signal, but enhance it. We cannot The more harmonics added, the more perfect the see 3.58 MHz variations in picture brightness at square wave. This sinusoidal make-up of a square normal viewing distance. We just see solid blocks of wave is significant because tuned circuits such as brightness. Conversion of 7 MHz and 3.58 MHz sig- those found in a television receiver respond to the nals to solid gray levels does not, therefore, degrade sinusoidal components of signals. A square wave the picture we perceive. will be processed as the sum of its sinusoidal A very interesting special case among Apple components. PICTURE signals is that created by turning alter- Generally, Apple PICTURE signals, which pro- nating groups of three HIRES40 dots on and off. duce color displays, are 3.58 MHz square waves. Conventional Apple wisdom is that this will createa These square waves modulate a television carrier horizontal dashed line with white coloration of the frequency in the user supplied modulator, creating dashes because they are three adjacent dots. How- a radio frequency with a square modulation enve- ever, the picture signal produced by this pattern is a lope. Sinusoidally, the square wave intelligence is square wave of 3.58 MHz/S. This square wave has carried by the following series of frequencies: significant 3.58 MHz sinusoidal content, since 3.58 carrier MHz is the third harmonic of the fundamental carrier + 3.58 MHz square wave frequency. This produces a 3.58 MHz carrier + (3.58 MHz) x 3 sine wave at the output of the chrominance ampli- carrier + (3.58 MHz) x 5 fier about 1/3 the amplitude of the signal produced by a 3.58 MHz PICTURE signal. The result is a washed out coloring of the 3.58 MHz/3 PICTURE signal, not nearly as intense as the coloring of 3.58 MHz PICTURE signals. The chrominance ampli- The IF strip of the television will pass the sine fier frequency band is from 3.1 MHz to 4.1 MHz, so wave carrier and those sine wave frequencies above any PICTURE signal from 3.1 MHz/3 to 4.1 MHz/3 the carrier, up to carrier + 4.2 MHz. Only the carrier should have some coloration. and carrier + 3.58 MHz of the above distribution are A second television phenomenon is less predicta- within this range. As a result, the 3.58 MHz square ble. Many televisions have a coupling transformer envelope is converted to a 3.58 MHz sinusoidal enve- or inductor/capacitor combination at the input to lope, and the output of the second detector in the the chrominance amplifier, I have found that this television is a 3.58 MHz sine wave. This sine wave is input circuit has a marked tendency to ring at 3.58 8-48 Understanding the Apple He MHz when the PICTURE signal switches from rier +3.58 MHz resides midway between the "car- white to black or black to white. This ringing pro- rier + 227(horizontal freq)" and the "carrier + duces an output from the chronninance amplifier of 228(horizontal freq)" energy concentrations of the about the same amplitude as that produced by a 3.58 lum inance signal. The "carrier + n(horizontal freq)" luminance distribution is thus interlaced with the MHz/3 PICTURE signal. One result is edge color- ing of white screen displays. The 3.58 MHz ringing "carrier + 227.5(horizontal freq) + n(horizontal should vary greatly from television to television, and freq)" distribution. This reduces interference be- tween the chrominance and luminance signals. may be reponsible for many of the off-color edges The Apple PICTURE signal is high in horizontal found in Apple displays. In a normal television broadcast signal, the lumi- frequency harmonic content, just like the normal nance signal energy is concentrated at multiples of television luminance signal and color signals. There- the horizontal frc(iuency removed from the picture fore, the energy of the modulated carrier should be carrier. This is because the luminance signal itself distributed primarily at "carrier + n(horizontal has a very high content of harmonics of the line freq)" intervals. The process of modulating a 3.58 scanning freiiuency. When the luminance signal MHz subcarrier with a color signal does not take modulates the carrier, theenergj' is largely distrib- place, so the "carrier + 3.58 MHz + n(horizontaI uted in groui)s centered at the following frequencies: freq)" energy distribution should not exist to the carrier same extent as it does in a normal television chromi- nance signal. However, the 3.58 MHz PICTURE carrier + horizontal frequency signal with horizontal frequency harmonic perio- carrier + 2( horizontal frequency) dicity should create some elements of the "carrier + 3.58 MHz + n(horizontal freq)" distribution when the carrier is modulated. It is, therefore, interesting to note that the 3.58 MHz COLOR REFERENCE The color signals have a similarly high content of signal of the Apple is 228 times the horizontal fre- horizontal frequency harmonics. When the 3.58 quency, not 227.5 times the horizontal frequency as MHz color subcarrier is modulated by a color signal, in a normal television signal. This means that the the onergj' is largely distributed at "carrier + n( horizontal freq)" energy distribution is 3.58 MHz (suppressed) superimposed, rather than interlaced, with the 3.58 MHz + horizontal fretiuency "carrier + 3.58 MHz + n(horizontal freq)" distribu- tion. My conclusion is that the energy of a carrier 3.58 MHz + 2(horizontal frequency) wave modulated by Apple video is largely distrib- uted at multiples of the horizontal frequency removed from the carrier frequency, with no inter- laced distribution induced by the chrominance The 3.58 MHz color subcarrier is used because car- element. . ■,j.iil;»!ii§ili» DATA BUS chapter 9 The Disk Controller READ PULSE READ FACE LOGIC STATE INTER- SEQUENCER [^ WRITE SIGNAL CONTROLLER DISK DRIVE The long term success of the Apple II line of com- It is primarily the controller circuits and the puters could not have come about without the devel- available disk operating systems which determine opment ofthe Disk II 5 M inch floppy disk drive. For the features of disk operation that are unique to the simple storage of data and programs, disk I/O is Apple, and it is the controller circuits which are the merely faster and more convenient than cassette main topic of this chapter. General features of the 'I/O. But for important computer uses such as word disk drive are also discussed, but no attempt is made processing, data base management, business ac- here to document the disk operating systems beyond counting, and file handling, the disk drive or its the RWTS (Read or Write a Track and Sector) sub- equivalent is mandatory. There can be no doubt that routine of DOS 3.3, the DIIDD (Disk II Device for most owners the disk drive is the most important Driver) subroutine of ProDOS, and the disk data peripheral in the Apple He computer. formats of DOS 3.2, DOS 3.3, and ProDOS.* Since the original Apple II was strictly cassette based, the interface to the Disk 11 had to be built on a peripheral card , The extent of motherboard su pport DISK II OVERVIEW of the Disk II is an empty card slot and the mother- Near the end of 1977, Apple Computer's decision- board firmware. Motherboard firmware includes making group was still very small. Mike Markkula, no disk handling routines but only looks for disk the chairman of the board, presented the group with handling routines in the peripheral slots and jumps a list of products needed to be developed for the to them at power up. The bootstrap program and Apple. At the top of the list was a floppy disk drive the circuits that interface the computer with the for the Apple II. Within a very short period of time. drive are on the disk controller, which is a pe- ripheral card usually installed in Slot 6. The disk ♦Operation of DOS 3.3 and ProDOS are weil documerted in the controller is connected by a 20-wire ribbon cable to books Beveath A pple DOS (Qual ity Software, 1982) and Beneath the disk drive, which contains more electronic cir- Apple ProDOS (Quality Software, 1984) by [ton Worth and cuits as well as the drive mechanisms. Pieter Lechner. ***:;: 'rtEa,^ ^ ■. 9-2 Understanding the Apple lie stored track number from the disk and comparing Apple developed the Disk II and released it along it to the track number it is attempting to access with its operating system, DOS 3. Figure 9.1 is a functional diagram of Apple He The disk drive chosen by Apple was a Shugart disk I/O. Data transfer between the MPU and the SA400. Apple designed their controller card controller is 8-bit parallel via the data bus. Control (mounted in a peripheral slot), analog card (mounted in the disk drive), and data formats around this by the MPU is via the address bus, of course.* Data standard drive. More recently, companies other transfer between the controller and the drives is than Shugart have made the Disk II drive for Apple, serial, and control of the drives is via multiple con- but the Disk 11 has always been nearly identical to trol lines serving various functions. The controller is the old Shugart drive. Additionally, other Apple primarily a digital data processing device, whilethe analog circuit card in the disk drive performs the drives such as the twin half-height drive and the functions of amplification, shaping, and gating. Apple lie built-in drive perform identically to the Disk II. That is. they are single sided, single density Control of the disk is software intensive, meaning drives that support 35 tracks and 143,360 bytes of very little is done automatically by hardware. data on 5 V4 inch floppy disks. Hard sectored disks are disks with little holes in Various companies make other drives and con- them which divide the disk into a number of sectors. trollers which will work in the Apple He. These Disk drives supporting hard sector formats have a drives are generally less expensive than their Apple sensor in them which signals the host computer counterparts and they work perfectly well with when a hole is passing by and allows a program to DOS 3.3, ProDOS. and the Disk II controller. The determine where the disk is in its circular trip. The main disadvantage of buying alternate source disk Disk II does not have this feature, and Apple disk drives is that you do not receive the excellent docu- operating systems don't require it. Instead, the mentation that comes with an Apple drive. This Apple uses a soft sectored format in which posi- documentation, however, can be purchased sepa- tional information is stored on the disk in uniquely rately from retailers who carry Apple products. identifiable address fields. These address fields are Other compatibledrives and controllers will besim- the "holes" which divide the disk into sectors and ilar, but the discussions in this chapter detail the identify rotational position. The address fields eon- operation of the Disk II controller and, to a lesser tain an address field identifier and a volume-track- extent, the Disk II drive. sector address from which programs can locate Floppy disks are magnetic media, just like audio specific address fields. Behind each address field, and video tapes. Reading and writing is performed there is adata field with space for 256 bytes of data. by rotating the disk while a stationary read/write An address field and the data field that follows it head presses against it. Disk speed is 300 RPM make up a sector of disk information.** which translates to 48.4 inches per second on the DOS 3.3 and ProDOS write 16 sectors (address inner track. This is a great deal faster than audio fields followed by null data fields) in their disk for- cassette tape speed, so the rate of data transfer is matting routines. The 16-sector format is not greater than that achieved in an audio cassette stor- unconditionally dictated by hardware. It is just a age system. very reasonable number of sectors to have, consider- In between read or write periods, the head may be ing the facts that the 6502 addressing modes are positioned radially so that different tracks can be best suited for manipulation of datablocks up to 256 written to or read from. The head is positioned pre- bytes in size, that 256 bytes is a workable size for cisely bya stepper motor under 6502 program con- trol. There are 35 tracks on the Disk II, but some data blocks in disk I/O, and that the Disk II is capa- ble of storing 16 sectors of 256 bytes on a track in the second source drives have 40 or more tracks which can be utilized by modifying DOS 3.3 or ProDOS. DOS 3.3/ProDOS format. As an example, the hard- ware will let you store data in eight sectors of 512 There is no hardware sensor that can be used to bytes each. Sixteen sectors of 256 bytes, however, is determine which track the head is on. The bootstrap program absolutely determines where the head is *In thischapter there is much discussion of the roUof the MPU in 'MSi ' by running it against the outer stop at initialization. disk I/O. The reader will do well to remember that while the From that point the controlling DOS closely moni- MPU has certain capabilities of manipulating the Disk 11 hard- tors head location, always saving the current posi- ware, these capabilities can only be utilized under T>TOgr»m±^ DISK DRIVE Figure 95 Data Transfer In Disk I/O. *,#^ The Disk Controller 9-S logic state sequencer on the controller. The logic analyze the sequencer in great detail, but first we state sequencer is a ROM together with some flip- need to lay the groundwork by looking at the hard- flops wired up to act like a little 2 MHz computer. It ware environment. has a stored program which it sequences through while executing commands that control the data THE DISK II DRIVE register. Some writings refer to the sequencer as the "state machine," but logic state sequencer more Figure 9.3 is a functional diagram of the Disk II clearly describes its functions. Via address bus drive. The intention here is not to explain all details commands, a 6502 program can configure the of floppy disk drive operation, but only to establish sequencer to shift out write data, shift in read data, the basis of control of the drive from the computer. or shift in the state of the write protect switch in the In addition to Figure 9.3, reference to Figure 9.1 disk drive. should help clarify the points of discussion. Even In the write process, a 6502 program causes the though only the Apple Disk II is mentioned, most of MPU to store a byte of data in the data register of the the discussion is also valid for substitute drives. As controller. The logic state sequencer shifts this Figure 9. 1 i ndicates, all connections to the drive are information, monitoring each bit individually. routed to the controller. Every time the sequencer sees aONE, it toggles the Power Supply WRITE signal. This changes the direction of mag- netic field in the read/write head. As the disk The drive takes its power supply voltages from the passes across the head during write operation, the Apple's main power supply. +12V, -12V, and -5V surface of the disk near the head is magnetized, and are all utilized, but only +12V is used for motor the direction of field in the head determines the drive. Since +12V is used both to position the head direction of the magnetic field on the disk. When the and rotate the disk, the load on +12V is significant, writing stops, the data remains on the disk in the especially at disk start-up. The drive has a high form of transitions or lack of transitions in the mag- capacity +12V input filter to assist the Apple's netic field. Disk I/O is identical to cassette I/O in this power supply in supplying motor start-up current. regard. Serial data is stored in the form of magnetic field reversals on the medium. A ONE is a field The Drive ENABLE' Input reversal. A ZERO is the lack of a field reversal. The ENABLE' input is low at drive 1 or drive 2, Reading is the reverse of writing as far as the but not both, when a drive is being accessed. At the read/write head is concerned. As the disk rotates, enabled drive, the drive motor is on, the IN USE magnetic field reversals on the moving disk surface indicator glows, head positioningisenabied.and the cause voltages to be induced in the head. The voltage read pulse output and the state of the write protect pulses are sensed by a special purpose floppy disk switch are enabled to the controller. Speed of disk read interface chip which puts out a nice square rotation is regulated by a motor speed control board read pulse for every magnetic field reversal on the in the back of the drive. This speed is adjustable via disk. The sequencer monitors these read pulses and a potentiometer on the speed regulator board. shifts ONEs and ZEROs into the data register based on the presence or absence of the read pulse at the The Head Positioning Mechanism normal write interval. The head assembly is positioned precisely, via a The sequencer syncs up on the read data if it was stepper motor. The stepper motor, which rotates, is written properly. This means that it will shift data linked mechanically to the head assembly, which into the data register until a complete byte is shifted travels linearly. A 6502 program positions the head in, then it holds that complete byte long enough for a assembly by directly controlling the four phased 6502 program to detect it by polling the data regis- inputs to the stepper motor. ter. The program recognizes that the data register Figure 9.4 is a functional diagram of a 4-phase holds a valid byte when the most significant bit of stepping motor, which can provide a basis for the register is set. When a val id byte is detected, the understanding the positioning of the read/write program must quickly process or store the byte and head. The rotor is a cogged ferrousdrum whose cogs start checking the data register for the next one. may be attracted by one of four electromagnets. The It can be seen from this overview that the key to electromagnets are activated sequentially under understanding how data is transferred to and from program control. There may be any number of cogs the disk is the logic state sequencer and how it is on the rotor, but only one of them is next to one of the manipulated by the 6502 program. Later, we will four electromagnets at any time. "*jlE5f« 9-6 Understanding the Apple He 11:=. OPEN COLLECTOR COIL DRIVERS 20 PIN RIBBON CABLE CONNECTOR TO CONTROLLER PLUG 1 STEPPER 0 Phase-O [T]- -"(^^3 UULA/ "XAAA^ STEPPER 1 Phase-1 0"*" -CD- STEPPER 2 Phase-2 6 h»- STEPPER 3 Phase-3 |T]-»^ "\AAAJ~ OPEN WHEN WRITE PROTECTED ■^USE 1.3.5,7 groumd|^^ t12V INDICATOR 13,15.17.19 GATE GATED *12V H2vQ-»- ■TO WRITE/ ERASE GATE DRtVE DRIVE MOTOR MOTOR ENABLE' ■OlH-T CONTROL *12V 'mil WRITE r^oi PROTECT lilir i5V IC MC3470 READ nri GATED PULSE [llr FLOPPY DISK READ INTERFACE WRITE ENABLE' ENABLE I. I WRITE/ ERASE R/W HEAD GATE WRITE REQUEST' WRITE 10 h*- X>^0-T^ SIGNAL ERASE 18 k*- 11,12 HEAD OISK Q-^«5V >> MOTION [?}-*-12V Figure 9 3 Functional Diagram: The Disk Ii Drive. f-s-^i:^ The Disk Controller 9-7 Phase-O Phase-1 Phase-2 Ptiase-3 RETURN Figure 94 A Stepping Motor. To rotate the rotor one step to the right in Figure that the high/low state of the WRITE signal deter- 9.4, energize the phase-2 magnet, then deenergize mines the direction of the magnetic field set up in the phase-1 magnet. Magnetic attraction will then the read/ write head. align the cog with the phase-2 magnet. To go three Current in the read/write head tends to produce steps left from this new position, perform this pro- magnetic fields on the disk parallel to disk motion. gression; phase-1 on, phase-2 off, wait, phase-0 on, Current in the erase head tends to produce magnetic phase-1 off, wait, phase-3 on, phase-0 off, wait. The fields on the disk perpendicular to disk motion. The wait is for the response time of the motor, which is actual strength and direction of the fields produced slow compared to the MPU. Summarizing, to step are a result of the vector sum of the WRITE signal left, sequence through the phases in descending field and the erase field (see Figure 9.5). The pres- order. To step right, sequence in ascending order. ence of the erase field means that there is always The Apple disit drive uses a 4-phase stepper motor some field in the head assembly while writing, even for head positioning. The controller has provisions in themiddleof a WRITE signal fieid reversal. The for bringing the control voltage for each phase high absenceof a field in the head assembly would allow or low individually. In the drive, these voltages will previous field alignment on the disk to remain turn.on or cut off current to the electromagnets in unchanged. Thus, the erase field causes the pre- the stepper motor. A good deal of the software over- viously written data to be erased when the WRITE head isrequired to position the head and remember signal component of the field vector has an ampli- its location (see PROGRAMMING EXAMPLES tude of zero. FROM RWTS later in this chapter). Two phases As was mentioned in the overview, data bits are must be stepped through to move the head one track , stored on the disk as field reversals, or the lack of /nd the Disk II and standard versions of RWTS and field reversals, at a regular interval. This fact is not DIIDD support 35 tracks on a disk. changed by the presence of the erase component in the field. Just understand that the erase, or radial, ^Writing to the DPsk component is constant, while the read/write, or tan- ,^ There are two write related inputs from the con- gential, component reverses depending on the troller tothe drive, WRITE REQUEST' and the WRITE signal. rNRlTE signal. WRITE REQUEST' causes the irive to be configured for writing unless the disk is The Wf ite Protect Switch fi^rite protected. Configuring the drive for writing There is a spring loaded switch in the Disk 11 insists of allowing the WRITE signal to control drive which is open when a write protected disk is he current in the coil of the read/write head, and of installed. A write protected disk is one with no notch applying a direct current to a second head referred on the left edge or one with the notch covered up. 0 here as the erase head. The WRITE SIGNAL ontrol of the current in the read/write head is such Having this switch open causes the WRITE PRO- TECT signal to be high, which isolates the WRITE A^tt 9-8 Understanding the Apple lie MAGNETIC FIELD REVERSAL READ/WRITE HEAD EKASE HEAD •ICV ■r~^ WHILE WRITING Figure 95 The Write Field is the Vector Sum of ttie WlilTE and ERASE Fields signal from the read/write head even if WRITE undesirable effect — perhaps a tiny vibration or REQUEST' is low. The WRITE PROTECT signal overheating of the motor. In any case, the RWTS is also routed from the enabled drive to the con- and DIIDD head positioning routines leave all four trol er so a 6502 program can determine the state of phases off after head positioning. The boot routine the write protect switch. on the controller card, however, leaves phase-0 The WRITE PROTECT signal and the read pulse energized after sending the head to track 0. are the only two outputs from the drive to the con- troller (see Figures 9.1 and 9.3). Both are output The Read Pulse through tri-state drivers which are gated by the drive ENABLE' input. This allows the two drives to When writing is not enabled, passing a field re- share control of the read pulse and write protect versal on the surface of the disk over the read/write lines. head induces a voltage in the coil. This induced volt- An interesting feature of the write protect circuiy- age will alternate in polarity for every field rever- ry is that its activating voltage is the phase-1 voltage sal. The induced voltage is sensed by a special inputtotheheadpositioningmotor(seePLUGl.pin purpose chip which is designed for this function. 4 in Figure 9.3). As a result, phase-1 must be turned off after head positioning or writing to the disk is The special purpose chip, a Motorola MC3470, out- puts a positive 1 -microsecond pulse for every field impossible. This is probably a way of forcing the reversal (see Figure 9.6). This read pulse is routed programmer to turn off all phases (not just phase-1) from the enabled drive to the controller. after head positioning. This seems to imply that keeping a stepper motor input active causes an Now we come to the biggest problem with reading a disk. The signal coming off the read/write head is The Disk Controller 9-9 THE WRITE INTERVAL IS FOUflMPUCVCLES WRITE SIGNAL CORRESPONDING READ PICK-UP VOLTAGE READ PULSE FROM MC3470 Figure 9A When Reading, the Lack of a Read Pulse at a Regular Interval Represents a ZERO. adirty little voltag-e. The shape and size of this read starts puttingout false read pulses. This means that pick-up signal will vary with disk speed, tempera- you can't utilize copy protect schemes that call f()r ture, humidity, head alignment, disk warpagfe, and i.solated field reversals on the disk separated by Murphy's Law in the read environment as opposed large intervals of constant field diroclion. In other to the same factors in the write environment. The words, the MC3470 will reliably produce rt';i phases must be turned off in rapid sequence if one of and output port addresses used by RWTS forcould trans- nem phase 1, thedrive is unmodified, and data is to be written on the isquarter fer of disk data. In reality any even address be track. used to load data from the data register to the MPU, •**!!•:_ 9-14 Understanding the Apple lie Table 92 Funclions of the $C08CX/$C0eD,X and $C08E/$C06F Switches. shift/load read/write Sequencer Funct.ion $C08C,X ?C08F,X Data register shift every eighth sequencer' clock while writing. $C08D,X $C08F,X Data register load every eighth sequencer clock while writing. $C08C,X $C0BE,X Enable READ sequencing - $C08D,X $C08E,X Check state of write protect switch and initialize sequencer for writing. although $C088 (DRIVES OFF) and $C08A (SE- The A2 and A3 inputs allow the 6502 programmer LECT DRIVE 1) would be inappropriate for this to configure the sequencer for loading while writ- purpose. Use of $C08D,X as the output address goes ing, shifting while writing, reading data from the hand in hand with the fact that it causes loading of disk, or checking the write protect switch. The Al the data register from the data bus. and A4 inputs allow the sequencer flow to deviate depending on the presence or absence of a read pulse The Logic State Sequencer and and the state of shifted data in the data register. Data Register The data register is a very versatile 8-bit IC that As mentioned before, the logic state sequencer is can shift left, shift right, load parallel or store paral- lel based on its control inputs. The remaining four a ROM wired up to behave like a little 2 MHz com- puter. Itis this powerful sequencer that enables the outputs of the sequencer ROM are connected to controller to perform such complex control with so inputs of the data register, completing our picture of few chips. It uses a 256-byte ROM with four of its the sequencer. Four of the ROM data bits are pro- data outputs (04—07) connected through flip-flops grammed tocontrol sequencing and the other four to four of its address inputs (A5, AO, A6, and A7). data bits are programmed to control the data regis- The flip-flops are clocked by Q3 falling while a ter. There are only six distinct commands which the drive is enabled.* sequencer can cause the data register to perform, There are eight address inputs to the sequencer but there are 16 possible states of the command bits, due to redundant states which command the data ROM, so let's refer to the four flip-flop latched end register to do the same thing. Table 9.3 shows the around inputs as the sequencing inputs and the other four address bits as the partitioning inputs. 16-bit states in hexadecimal and binary with an Assume for a moment that the four partitioning asterisk next to the six states used by Apple to per- inputs are fixed. The overall ROM address will then form commands in their DOS 3.2 and 3.3 ROMs. change every time Q3 falls, and the contents of bits In addition to the sequencer control of the data 04—07 of any addressed location will determine the register, any reference to even addresses in the address after the next clockpulse. These four data DEVICE SELECT' range of the controller slot will bits thus contain flow information, and they are cause the contents of the data register to be placed programmed so the flow will proceed in an orderly on the data bus. For this reason, programs should manner from clock to clock. There are 16 states of not cause the MPU to write to even addresses or the the four sequencing address inputs and 16 states of bidirectional peripheral data bus driver will com- the four partitioning address inputs. The sequencer pete with the data register for control of the periph- ROM is thus divided into 16 partitions of 16 se- eral data bus. It is important to note that, while a quencer states each. 6502 program can check the state of the data regis- The four partitioning inputs are: ter at any time, a program can store data to the data register only when the sequencer is performing a Al — QA, the MSB of the data register A2 -SHIFT/LOAD, the $C08C,X/$C08D.X load. As a result, the write operation involves get- switch ting the 6502 program in sync with the sequencer A3 -READ/WRITE, the *The sequencer clock is actually the risinjredge of Q3', developed $C08E,X/$C08F,X switch by gating: Q3 through a 74LS132 NAND gate {see Figure 9.8). Due to propagation delay, the clock is effectively Q3 falling plus A4 —The read pulse from the disk drive approximately 15 nanoseconds. The Disk Controller 9-15 and keeping it there by performing write operations During both reading and writing, the data regis- in exact timing loops . If the data register is to accept ter ishifted left while its most significant bit, QA, data from the MPU, the 6502 program must store is monitored. In writing, the state of QA is moni- the data to the data register at exact multiples of tored and the WRITE SIGNAL is toggled at the bit the bit writing interval. This interval is eight writing interval when QA is set. In reading, ONEs cycles of the sequencer or four cycles of the MPU. and ZEROs are shifted into the data register depend- It is important to make a distinction here between ing on the presence or absence of a read pulse at the what can be done and what normally is done. A bit writing interval. When QA becomes set, the program can store data at any multiple of the bit sequencer holds the data register long enough for a writing interval— 8, 12, 16, 20, etc, MPU cycles— 6502 program to detect the valid byte with a seven and the data register will accept it. However, RWTS MPU cycle polling loop. Then the data register is and DIIDD only store data to the data register at cleared and the next byte is shifted in from the disk. 32-, 36-, and 40-cyele intervals. There are very prac- tical reasons for this which will become apparent as Decoding the Contents this discussion progresses. of tt>e Sequencer ROM Both the sequencer control flip-flops and the data In the past, the contents of the logic state se- register are clocked by Q3 falling when a drive is quencer ROM have been a mystery in the world of enabled. This means the sequencer operates at Apple users. The basic reason for this is that no one approximately 2 MHz, twice the frequency of the who understood the contents ever bothered to pub- 6502. Additionally, the read pulse from the enabled lish any information about it. A primary aim of this drive is synchronized to the Q3 falling clock, quant- chapter is to fill this gap in Apple literature by ized inpulse width to one Q3 period, and inverted in providing formatted listings of the DOS 3.2 and the process to form a negative pulse. It is this syn- DOS 3.3 sequencer ROM* contents and discussing chronized, negative read pulse which is applied to operational aspects of disk I/O which are deter- A4 of the sequencer ROM, and the read pulse is mined by the contents. therefore monitored in the same 500-nanosecond This section shows how to make the contentsof the time frame as the other addressing inputs to the sequencer ROM accessible to the MPU and provides ROM. In a further attempt to stabilize the shaky read pulse, a Schmidt trigger type NAND gate is *The logic state sequencer ROM was changed when Apple upgraded from DOS 3.2 to DOS 3.3 so the two versions of the used in the read pulse quantizing circuit (see Figure ROM are referred to here as the DOS 3.2 and DOS 3.3 versions. 9.8). Use of this type of gate increases noise immuni- The DOS 3.3 version has slightly different read sequences which ty and ensures smooth transitions of the A4 input to improve the read reliability in the 16-seclor formats of DOS .'1.3, the sequencer ROM. Pascal, and ProDOS. Table 93 Logic State Sequencer Commands. 03-02-01-00 • mx 0 BnuMs: MSEEtaSOJC FUNC'i'lCH 0000 CLA a.KAR DATA REGISTt;K 1 0001 GLR C\R 2 0010 3 0011 a,R 4 0100 GLR 5 *8 0101 a,R 6 *9 0110 CLR 7 *A 0111 a,R *B 1000 NOP NO OPERATION 1001 SUd SHIFT ZERO LEitT INTO DATA REGISTER *D 1010 SR SHIFT WRITE PROTECT SIGNAL RIGHT INTO DATA REGISTER 1011 IJJ LOAD DATA REGISTER FROM DATA BUS C 1100 NOP 1101 sr,i SHIFT ONE TfTT INTO DATA REGISTER E 1110 SR P 1111 ID K''^ 9-16 Understanding the Apple He 3. A natural significance order of addressing a program which makes formatted listings of those inputs to the sequencer ROM is WRITE— contents. The program will accurately list the con- READ PULSE~SHIFT/L0AD-QA-07-. tents of any ROM designed to operate in the B3 06—05—04. This does not correspond to the socket of the Disk II controller. It is not necessary for way they are con neeted to A 7 th rough AO on the the reader to go through the exercise of making listings of the DOS 3.2 and DOS 3.3 sequences since sequencer ROM. 4. The read pulse applied to A4 of the sequencer these listings are furnished in Figures 9. 10 and 9.11. ROM is a negative pulse. He may, however, find it interesting and educa- tional tomake his own listings^ These wiring connections were not designed to The MPU cannot normally read the contents of confuse us, although they serve the purpose. They the sequencer ROM because the ROM is not con- \j(ere designed to minimize wire crossover on the nected tothe data bus. You can change this situation mechanical layout. A design engineer can swap the by removing the bootstrap ROM from the D3 socket address and data pin assignments on a ROM until he and moving the sequencer ROM from the B3 socket finds his own version of peace of mind, then he com- to the D.S socket. The contents of the sequencer ROM pensates for the scrambled pin assignments when can then be read by the MPU by addressing $C6XX he writes the ROM program.* The sequencer ROM (assumes Slot 6). Of course, your disk drive won't formatting program must account for this by read- work with the controller configured this way, but ing each byte of data, unscrambling address bits to you can save the data to cassette tape and then find where that data is in the sequence, and revers- transfer it to a disk file when your controller is back to normal. ing data bits before storing them in a 16 x 16 string variable matrix from which listings can easily be This data can be listed to a printer using the moni- made. tor, but it is not particularly readable in this form. I The result is the listings of Figures 9.10 and have written a BASIC program to format the data into a readable listing. Figures 9.9 through 9.11 9.11.** The WRITE and READ sequences are contain listingsof the Applesoft BASIC formatting separated from each other, and the listing is other- wise divided into columns of 16 sequencer states. program, the DOS 3.2 sequencer, and the DOS 3.3 This is a natural division since 16 different values sequencer respectively. The program was written in BASIC rather than assembly language so it could be can be represented by the four sequencingdatabits. more easily understood by readers who choose to The far left hand column is the sequencer state, and the other columns hold the contents of the ROM for study it. Also, readers should find it very easy to th at sequencer state. The left digit of each number manipulate the sequencer listing because it is for- is the next sequencer state, and the right digit is matted as a 16 by 16 BASIC subscripted string the command. Next to each number is a mnemonic variable. The program takes a little over a minute to for the command digit. run. It will list any sequencer ROM designed to run in the Disk II controller as long as its source file is *Steve Wozniak designed the Disk II controller. Working with read from the DSsocketof the controller. The source Randy Wigginton, Wozniak completed this complicated and file needs to be resident on diskette as a binary file innovative design in the space of one week (the final week of 1977). Steve is very proud of the nnechanical layout and at one named "SEQROM". However, it would be easy to tl me red id the lay out for the sole purpose of reducing the number change line 50 of the program so the source file can of feed-through holes from three to two. I had long assumed that be obtained elsewhere. Before running the pro- much of Apple's disk interface technology had been borrowed gram, enable the 80-column display or an 80-column from Shugart, but I couldn't have been further from the truth. printer. The format and circuitry represent a notable creative effort by The manipulations of the program are based on the Apple group. Besides the controller design. Wozniak wrote the following features of controller wiring: RWTS. Randy Wigginton wrote the restof the original DOS. and Rod Holt designed the analog board of the disk drive. 1. Address bus AS is connected to the A7 input to the D3 socket. Address bus A7 is connected to "The formatted listings presented here are my own representa- the A5 input to the D3 socket. tions which resul ted from lengthy investigation. The mnemonics, 2. Data bus lines D4 through D7 are connected to address labels, and layout won't, therefore, be the same as those outputs 07 through 04 on the D3 socket in used by Apple engineers. Who knows what they use? 1 submit, reverse order. though, that my representation provides adequate illustration in the absence of any labels and formats published by Apple. )M The Disk Controller 9-17 10 REM 12 REM LIST IJOGIC STATE SEQUENCER ROM 14 REM BY JIM SATHER 15 RSI 2/22/83 16 REM 30 REM IHIS PROGRAM FORMATS AND LISTS IHE PROGRAM CONTAINED IN THE 32 REM DISK 11 LOGIC STATE SEQUENCER. BEFORE RUNNING THIS PROGRAM, 33 REM YOU MUST CREATE A BINARY SOURCE FILE ON A DISK AND 34 RHM NAME IT "SEQROM". THE SOURCE FILE IE CREATED BY PLACING 36 ISM THE B3 RDM IN TOE D3 SLOT OF THE DISK CONTROLLER. THE 38 RIM SOURCE FILE IS WRITTEN TO CASSETTE FROM $C600-SC6FF. WHEN THE 40 REM CONTROLLER IS RESTORED, THE CASSETTE FILE IS TRANSFERRED TO DISK. 42 R£M 50 PRINT CHR$ (4) ;"BLOAD SEQROM, A7936" 100 DIM LST(15,15): DIM ASWAP(7) : DIM DFIX(15) : DIM HEX$(15): DIM CMND$(15) 110 FOR X = 0 TO 7: READ ASWAP(X) : NEXT 120 FOR X = 0 TO 15: READ DFIX(X): NEXT 130 FOR X = 0 TO 15: READ HEX$(X) : NEXT 140 FOR X = 0 TO 15: READ CMNDS (X) : NEXT 150 GR : COLOR= 6: REM SOMETHING TO WATCH WHILE WAITING 200 REM 201 REM FORMAT DATA INTO 16 X 16 MATRIX 202 REM 210 EX3R COL = 0 TO 15: FOR ROW = 0 TO 15:WRK = ROW + 16 * COL 300 REM 301 REM GET BINARY FORM OF WRK 302 REM 305 FOR X = 0 TO 7:A(X) = 0 310 WRKI = WRK / 2:WRK = WRK / 2: IF (WRK - WRKl) THEN A(X) = 1 320 WRK = WRK%: NEXT X 400 REM 401 REM RECONSTRUCT DECIMAL WRK WITH ADDRESS BITS SWAPPED: 402 REM A7-A6-A5-A4-A3-A2-A1-A0 > A0-A2-A3-A6-A7-A5-A4-A1 403 REM THE DATA WILL THEN BE ADDRESSED BY THE WORD: 404 REM WRITE-READ PULSE-SHIFT/LOAD-QA-O7-06-05-O4. 405 REM 408 P0WER0F2 = 1 410 FOR X = 0 TO 7: IF A(ASWAP(X)) THEN WRK% = WRK% + PCiWEB0F2 420 P0WER0F2 = P0WER0F2 * 2: NEXT 500 REM 502 REM SWAP BITS D7-D4 OF DATA BEFORE SAVING, BECAUSE IMESE 503 REM BITS ARE SWAPPED ON THE D3 ROM. 504 REM 507 DTA = PEEK (WRK% + 7936) :HI = INT (DTA / 16) 510 LST(COL,ROW) = 16 * CDFIX(HI) + DTA / 16 - HI) 520 PLOT ROW.CGL: NEXT HOW: NEXT COL: TEXT 600 REM 601 REM 602 REM ADDRESS SWAP TABLE 610 DATA 1,4,5,7,6,3,2,0 620 REM 630 REM DATA SWAP TABLE 640 DATA 0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15 650 REM 660 REM DECIMAL TO HEX CONVERSION TABLE 670 DATA 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 680 REM 690 REM SEQUENCER CO^WAND TABLE 695 DATA -CLR,-CLR,-CLR,-CLR,-CLR,-CLB,-CLR,-CLR 700 DATA -NOP,-SLa,-SR ,-lD ,-NOP,-SLl,-SR ,-LD Figure 9.9 BASIC Listing; List Slat© Sequencer ROM (1 of 2). 9-18 Understanding the Apple He LISTING 802 REM AT THIS POINT IN THE PKOGRAM, THE SEQUENCER COLUMNS RESIDE S m 16 COLUMN S OF 16 SEQUEN CES. THESE 810 ^ E SECJUENCE 820 REM ARE ARRANGED SO EACH COLUMN CONTAINS mE COMPLET 830 REM FOR A StATE OF THE AmRESS WORD: REM WRITE-READ PULSE-SHIFT/U3AD-QA. 840 REM 900 „ 901 REM ********* LIST WRITE SEQUENCE 902 REM HEADING. 910 GOSOB 2000: GOSUB 2100: GOSUB 2200: GOSOB 2300: REM PRINT WRITE FOR COL 920 FOR = 0 TO ROW = 8T0 15 15: PRINT HEX$(R DW) ;"-"; 930 „.*-,, 16:L0% = (LST (COL,EOW) / 16 - HI%) * 16 940 HII = LST(COL,ROW) /%);HEX5(L 950 PRINT" ";HEX$(HI 0%);CMND5(LO%}; 960 NEXT COL: PRINT : NEXT BOW 999 GET B$: PRINT : PRINT 1000 REM 1001 REM ********* LIST READ SBQUMCE 1002 REM 1010 REM TOE READ PROGRAM IS EASIER TO UNDERSTAND WHEN THE 1020 REM LOAD PORTION IS SEPARATED FROM THE SHIFT PORTION AND 1024 REM WHEN QA' (QA LOW) IS SEPERATED FROM QA. THEREFORE 1030 REM THE COLUMN ORDER IS CHANGED IN THE READ LISTING. 1040 REM 1045 REM COLUMN ORDER DATA FOR READ LISTING 1050 DATA 0,4,1,5,2,6,3,7 1055 IF FLAG THEN 1070 1060 FOR X = 0 TO 7: READ CSWAP(X) : NEXT :FLAG = 1 1070 REM 1080 GOSUB 2400: GOSUB 2500: GOSUB 2600: GOSUB 2700: REM PRINT READ HEADING. 1090 FOR ROW = 0 TO 15: PRINT HEX? (ROW) ;"-"; 1100 EX)R COL = 0 TO 7 1110 HII = LST(CSWAPCC0L),ROW> / 16:L0% = (LST(CSWAP(COL) ,ROW) / 16 - HI%) * 16 1120 PRINT" ";HEX$(HI%);HEXS(IXi%);CMND$(LO%); 1130 NEXT COL: PRINT : NEXT ROW; PRINT 1160 GET B$: PRINT : PRINT 1170 PRINT "CODE mEMONIC FUNCTION" 1180 PRINT " 0 CLR CLEAR DATA REGISTER" 1190 PRINT " 8 NOP NO OPERATION" 1200 PRINT " 9 SL0 SHIET ZERO LEFT INTO DATA REGISTER" 1210 PRINT " A SR SHIFT WRITE PROTECT SIGNAL RIGHT INTO DATA REGISTER" 1220 PRINT " B LD LOAD DATA REGISTER FRC»1 DATA BUS" 1230 1240 PRINT END " D SLl SHIFT ONE LEFT INTO DATA REGISTER" 1990 REM 2000 PRINT : PRINT ; SPC( 37) ; "WRITE": PRINT : RETURN 2100 PRINT " * READ PULSE * NO READ PULSE 2110 RETURN 2200 PRINT " * SHIFT * LOAD * SHIFT * WAD 2210 RETURN , *— QA.'— * QA *— QA' * QA *— QA' * QA *— QA' * 0^— 2300 2310 PRINT "SEQ PRINT : RETURN 2400 PRINT ; SPC( 37);"RERD": PRINT : RETURN 2500 PRINT " * SHIET * LOAD * 2510 RETURN 2600 PRINT " * QA' * QA * QA' * QA 2610 RETURN „ PRINT "SEQ 2700 PRINT *— RP *-N0 RP— * RP *-N0 RP— * RP *-N0 RP— * RP — ■*-'» ^^* 2710 : RETURN Figure 9.9 BASIC LIsHrtg: List State Sequencer ROM (2 of 2). ^iM^ i, ^ .►to... ■d^' The Disk Controller 9-19 WRITE *. READ PULSE— NO READ PULSE SHIFT * ■LOAD- -SHIFT * LOAD- *- -QA' — * QA * — QA'- -QA *— QA' * QA * — QA' * QA- SEQ L8-N0P 18-NOP 18-NOP 18-NOP 18-NOP 18-NOP 18-NOP 18-NOP 28-NOP 28-NOP 28-NOP 28-NOP 28-NOP 28-NOP 28-NOP 28-NOP 0- 39-SL0 39-SL0 3B-LD 39-SL0 39-SL0 3B-LD 3B~LD 3B-LD 1- 48-NOP 48-NQP 48-NOP 48-NOP 48-NOP 48-NOP 48-NOP 48-NOP 58-NOP 2- 58-NOP 58-NOP 58-NOP 58-NOP 58-NOP 58-NOP 58-NOP 3- 68-NOP 68-NOP 68-NOP 68-NOP 68-NOP 68-NOP 68-NOP 68-NOP 4- 78-NOP 78-NOP 78-NOP 78-NOP 78-NOP 78-NOP 78-NOP 78-NOP 5- 88-NOP 08-NOP 88-NOP 08-NOP 88-NOP 88-NOP 08-NOP 08-NOP 98-NOP 6- 98-NOP 98-NOP 98-NOP 98-NOP 98-NOP 98-NOP 98-NOP A8-N0P A8-N0P A8-N0P A8-N0P A8-N0P 7- A8-N0P A8-N0P A8-N0P BB-LD 8- B9-SL0 B9-SL0 BB-LD B9-SL0 B9-SL0 BB-LD BB-LD 9- C8-N0P C8-N0P C8-N0P C8-N0P ca-NOP C8-N0P C8-N0P A- C8-N0P D8~N0P DS-NOP D8-N0P D8-N0P D8-N0P D8-N0P D8-N0P D8-N0P E8-N0P B- E8-N0P EB-NOP E8-N0P E8-N0P Ea-NOP E8-N0P E8-N0P F8-N0P C- F8-N0P F3-NOP F8-N0P F8-N0P F8-N0P F8-N0P F8-N0P D- 88-NOP 08-NOP 88-NOP 08-NOP 88-NOP 08-NOP 88-NOP 08-NOP E- F- READ . Sh * . LOAD * •*I FT QA- **- -* RP— QA RP — -*-N0 RP- SEQ Qft. *. , -*-N0 RP-* * — RP * -NO RP — NO RP — D8-N0P 18-NOP 18-NOP 08-NOP 0A-SR 0A-SR 0A-SR 0A-SR D8-N0P 28-NOP 28-NOP 28-NOP 0A-3R 0A-SR 0A-SR 0- D8-N0P 38-NOP 38-NOP 0A-SR 0A-SR 0A-SR 1- 38-NOP 0A-SR 0A-SR 2- D8-N0P 48-NOP D8-N0P 48-NOP 0A-SR 0A-SR 0A-SR D8-N0P 58-NOP D8-N0P 5a-N0P 0A-SR 3- 0A-SR 0A-SR 0A-SR D8-N0P 68-NOP D8-N0P 68-NOP 0A-SR 4- 0A-SR 0A-SR D8-N0P 78-NOP D8-N0P 7a-N0P 0A-SR 0A-SR 0A-SR CA-SR 5- 0A-SR 0A-SR D8-N0P 88-NOP D8-N0P 88-NOP 0A-SR 0A-SR 6- D8~N0P 9a-N0P D8-N0P 0A-SR 0A-SR 7- 98-NOP 0A-SR 0A-SR 0A-SR D8-N0P 09-SL0 D8-N0P AB-NOP 0A-SR 0A-SR 0A-SR 0A-SR 0A-SR 8- CD-SLl BD-SLl B8-N0P 9- D8-N0P 0A-SR 0A-SR D9-SL0 39-SL0 D8-N0P C8-N0P 0A-SR 0A-SR 0A-SR 0A-SR A- 0A-SR 0A-SR B- D9-SL0 D9-SL0 D8-N0P A0-CLR 0A-SR ID-SLI 0A-SR 0A-SR 0A-SR C- UD-SLl E8-N0P E8-N0P 0A-SR 0A-SR PD-SLl FD-SLl 0A-SR 0A-SR D- F8-N0P F8-N0P 0A-SR 0A-SR 0A-SR DD-SLl 4D-SL1 E0-CLR E0-CLR 0A-SR E- 0A-SR 0A-SR 0A-SR F- 0A-SR CODE MNEMONIC FUNCTION 0 CLR CLEAR DATA REGISTER u NOP NO OPERATION » SL0 SR SHIFT ZERO LEFT INTO DATA REGISTER A B LD SHIFT WRITE PROTECT SIGNAL RIGHT INTO DATA REGISTER LOAD DATA REGISTER FROM DATA BUS a SLl SHIFT ONE LEFT INTO DATA REGISTER Figure 9.10 The DOS 35 Logic State Sequencer. 402 'nothing is done to the data register, but the se- instruction, ASL. From this point, we .sequence up quencer moves up to State 1. State 1 contains a to State F in column 5 or f> depending on whether 28-NOP, which causes sequencing to State 2 at the QA was set or reset by the SLO. From State F. the next clock. State 2 contains a 3B-LD, which causes sequencer will loop back to State 0 if QA is set, sequencing to State 3 at the next clock as well as the toggling the WRITE signal, or it will loop back to loading of the data register from the data bus. State 8. leaving the WRITE signal high, if QA is Now look again at Figure 9.13. The sequencer reset. clock edge in State 2 occurs while the MPU is plac- Now let's step back and look at what's happening. ing valid data from the "STA $C08F,X" instruction Writing to the disk is a load and shift process, a on the data bus, and it therefore has succeeded in little like HIRES pattern outputs but much slower. ■storing data to the data register. Note that a "STA Also, the MPU takes a very active role in the loading $COEF" (assumes Slot 6) would not have worked andshiftingof disk write data. There are two 8-Htate ■here because MPU data would have been on the data loops in the WRITE sequence. After initializing the ,bus at State 0 instead of State 2. Clearly, Apple WRITE sequence, data is stored in the data register designed the WRITE sequence to support the at a critical point in the A7' loop. As (quickly thereaf- features of the 6502 "STA ABSOLUTE,X " in- ter as the 6502 can do it, the sequencer is configured struction with no page crossing. to shift left at the critical point instead of loading. Now look back at Figure 9.11. Assume that when Then the MPU goes about its business while the the MPU stored data in the data register, it set Q A. sequencer continues looping, shifting the data regis- ■In fact, if the data was written by RWTSor DIIDD, ter. Ifthe sequencer senses Q A high, flow vectors it'sasurething—QA is set. We will see that all data to the opposite loop, toggling the WRITE signal. words that RWTS or DIIDD store to the disk have Figure 9.14 is a flowchart of the WRITE sequence, their MSB set. This means that instead of sequenc- ing to State 3 in column 7, the sequencer goes to which may help you interpret the listing. The flow- chart isreminiscent of the schematic of a flip-flop. State 3 of column 8. It makes nodifference here, but This is not surprising because the WRITE sequence It will when we reach State 7. Until that point is has functional similarities to a toggling flip-flop. reached nothing happens. At State 7, if QA is set, So, the sequencer outputs eight bits of data. What sequencing up the states continues, but if QA is then? Well, if the program controlling the MPU did reset, the sequencer loops back to State 0. Right nothing more, after the eighth bit was shifted out, ™*' QA is set, so the next state is State 8. the data register would be all zeroes and no more . When State 8 is entered from State 7, the WRITE field reversals would be written on the disk. This ?{^5l switches from low to high. Why? Because the constant field condition cannot be read by the drives WRITE signal is connected to the A7 input of the but results in sporadic read pulses. In other words, jquencer ROM. The sequencing address bits are the MPU needs to stay involved. Normally, the K h in I'gn .~^^~^^' so A7 is low in states 0—7 and states 8— F (see Figure 9.8). Now think MPU program will wait until the last bit has been shifted to the disk, then switch SHIFT/LOAD to 9-24 Understanding the Apple lie READ C08E.X LOAD C08D,X READ SHIFT /WR RIGHT CHECK > WRITE W. PROTECT LOAD SHIFT /\ LOAD(COeCI,X) SHIFT (C08C, X) LOAD DATA REGISTER FROM DATA BUS RESET "Y~ ^y^ "Y" WRITE SIGNAL LOW WRITE SIGNAL HIGH Figure 9 .1 4 Rowchart ol the Write Sequence. The Disk Controller 9-25 LOAD with a STA instru ction at the precise moment wrote data to a disk at a 4-cycle bit interval doesn't that the data register will accept it. This moment mean that read pulses are going to come back from occurs once every sequencer write loop, once every the disk at the same interval. In the first place, the eight sequencer clocks, or once every four MPU Apple has a built-in clockpulse jitter with every cycles. It takes 32 MPU cycles to output eight bits of 65th MPU cycle longer than the rest. Thiselongates information, so to continuously shift out informa- some write intervals by 140 nanoseconds, and it tion in8-bit groups, the MPU must store data at doesn't help. But normal problems with the floppy $C08D,X every 32 cycles, then immediately en- medium and drive inconsistencies are more signifi- able shifting; with a read access to $C08C ,X. This cant incausing read pulse variations. example writes a byte to the disk then begins writ- Realizing that the read pulse varies a lot, consider ing asecond byte. how this variation affects trying to detect the LOAD absence of a pulse. In reading the absence of a pulse, LDA 5C08D,X the READ sequence must wait a certain amount of LDA $C08E,X READ BMI ERROR WRITE PROTECT ERR time past the last actual pulse, then decide "there was definitely no pulse there; that sure was a LDA DATAl STA $C08F,X WRITE DATAl ZERO." In the absence of a clockpulse coming off CMP $C08C,X SHIFT {4CP) the disk, the previous read pulse, or ONE, becomes PHA the time reference for the absence of a read pulse, or (3CP) a ZERO. PLA (4CP) PHA (3CP) What if you have two ZEROs in a row'' Well the last ONE bit is the time reference for the second and PLA (4CP) BIT $0 (3CP) ail succeedingZEROsinastring. Suppose the read- NOP (2CP) ing drive rotates at 280 RPM but the disk was writ- LDA DATA 2 (4CP) ten using a drive that rotated at 320 RPM. You STA ?Cy8D,X LOAD (5CP): cannot read a long string of ZEROs under these conditions, because while the write interval was TOTAL = 32CP CMP $C08C,X SHIFT eight controller cycles, the read interval could be ten cycles. Furthermore, in the absence of field rever- The above example illustrates the principle of sals on the disk beyond three or so write intervals, writingcontinuous bytes of data: initiate the WRITE the read interface chip in the drive begins to gen- sequence, then store data every 32 cycles. This will normally be accomplished in 82-cycle loops. After erate invalid read pulses, Y'ou simply cannot read a long string of ZEROs, because your time reference storing the last byte to be written, wait 32 cycles, is unstable and your read interface can't do it anyway. switching READ/WRITE to READ on the"32nd cycle. You don't have to write in 32-cycIe loops. You How may ZEROs in a row can be read reliably? can store 6-bit data words in 24-cycle loops if you can Two, RWTS3.3and DIIDD never write more than figure out some purpose for it. You can store data in two ZEROs in a row, and RWTS 3.2 never \v rites any multiple of 4 cycles and the data register will more than one ZERO in a row. Of course, normal accept it. Read syncing leaders are written by stor- ing SPF to the data register in 36-cycle loops (DOS data bytes very often have more than two adjacent 3,2) or 40-cycle loops (DOS 3.3 or DIIDD).* This zero bits. These normal data bytes cannot be stored creates aseries of llllIlllO or 1111111100 strings directly to the disk but must be translated to disk which, we will see, syncs up the sequencer for read- compatible 8-bit words. It takes more than one ing following data, LOAD-SHIFT cycle to output a data byte, because Disk Data Formate 266 possible numbers can be represented in a nor- mal byte, but not nearly as many can be represented There is an inherent problem with stori ng data on if you place restrictions on the number of adjacent ZEROs. I'oppy disks. As their name suggests, floppies are ' There is a second restriction on data which the ess than rigid. This and other factors contribute to me following fact of life: just because some Apple Apple stores to the disk. The MSB is always set. The MSB is used by both the READ sequence and n some literature, the read syncing leaders are referred to as a «nesof autosync bytes or self-syne bytes. 6502 programs to define when a byte of read data is in the data register. The MSB is therefore not data 9-26 Understanding the Apple lie great. Apple improved the read reliability by chan? but the BYTE FLAG.* It serves as a data gap which ing the sequencer ROM. They also made the ques^ allows the READ sequencer to hold the previous tionable move of changing the Bootstrap ROM and byte in the data register for a long enough time that bootstrap procedure, the most notable result of a 6502 program can detect the presence of a com- which is that a 3. 3 controller will not boota3.2 disk plete byte in a 7-cycle polling loop: This incompatibility is due solely to program based POLLIT LDA $C08C,X conventions. The 3,3 controller is fully capable of BPL POLLIT reading anything written on 3.2 disks. The Apple Disk II was first released with DOS 3 The DOS 3.3 restrictions on written data are MSB and the associated controller. Then the DOS was setj no more than one pair of adjacent ZEROs, and at upgraded to 3.1, then 3.2, then 3.2.1 with no change least one pair of adjacent ONEs in bits 6 through 0. in written data format. This format will be referred D5 and AA are still used only as field identifiers, to here as the 3.2 format. The 3,2 data restrictions and they don't meet the pair of adjacent ONEs are MSB set and no two adjacent bits reset. All requirements. This is notable because it helps dis- sector data are written using the following 32 tinguish D5 and AA from the other valid written values: words. The restriction requiring a pair of adjacent RWTS 3.2 WRITE TABLE ONEs rules -out9695, A5, A9, and CA. Besides D5and BC9A - AB AD AE AF B5 B6 AA, the DOS- A3.3 6 written values are: -RWTS 3.3 WRITE TABLE BCA0 - B7 BA BB BD BE BF D6 D7 BA29 - B3 BC 97 9A 9B AE B2 BCA8 - DA DB DD DE DF EA EB ED BE 9D 9E 9F BCB0 - EE EF F5 F6 F7 FA FB FD BA30 - D3 A7 AB AC D9 DA AD AF BA38 CB BCB8 - FE FF - DE B4 B5 B6 B7 B9 DB BA BB BA40 BA48 - EC BD BF P2 CD CE CF The values D5 and A A are also valid, and they are - F6 D6 D7 E6 DC DD used as the first two identifying values which pre- BA50 - FF DP E5 E9 EA EB FE cede every add ress field and data field. A 5-bit word BA58 ED EE EF can contain 32 values, so the 3.2 writing process BA60 E7 F3 F4 F5 F7 F9 FA FB FC FD involves taking a 256-byte data block and translat- BA68 ing it into 410 5-bit words. The 410 5-bit words do not directly index the write table to find the byte to There are 64 values in the write table, so you can be written. Rather, the first word written directly guess that six bits are written per LOAD-SHIFT indexes the write table. The second index is an cycle, and a 256-byte block is written in 342 LOAD- exclusive-OR between the first and second words: SHIFT cycles. With the size of the data field in a Each following index is an exclusive-OR between sector thus reduced, Apple was able to increase the the current and previous word. At the end, a 411th number of sectors per track from 13 to 16. word ia written. The last word of the coded buffer The most recent development in the evolution of di rectly indexes the write table for this word. When Apple He disk I/O has been the release of ProDOS. this process is reversed in the read operation, each No changes were required in the sequencer ROM to byte has to be correctly read for the following bytes upgrade to ProDOS, and to a very great extent, to be read correetiy. The 41 1th word read serves as a ProDOS data formats are identical to those of DOS checksum and must be equal to the 410th decoded 3.3.* The same write table is used to encode data word or the read will be deemed unsuccessful and although the table format is different than that of revert to a try again loop. This check sum procedure RWTS 3.3 (see $FAOO-$FAFF of DIIDD), and is an effective method of verifying the validity of address and data fields are identified with the same disk data transfer. series of bytes. Sectors on a ProDOS formatted disk Apple increased the disk data density in the DOS can be read and written by RWTS 3.3, and pairs of 3.3 upgrade by easing the restriction on adjacent sectors on a DOS 3,3 formatted disk can be read and ZE ROs. The 3,2 controller can read this data, but it's written by DIIDD. There are some minor differ- a struggle and the possibility of reading errors is ences between DOS 3.3 and ProDOS formats (see *Steve Wozniak originally devised the Apple disk formats. In a speech given in Anaheim. California, on April 17, 1983, he said •The equivalence of DOS 3,3 and ProDOS data formats extends that his idea for flagging groups of data by having every eighth only to data encoded on the disk at the track/sector level. As has been mentioned, file structure in the two operating systems is bit set came directly from the "stop bit" used in RS232 data transmission. completely different, as is the treatmentof data as 2-sect»r blocks by ProDOS. The Disk Controller 9-27 Figure 9. 15), but they do not affect operation and do desired address field has passed bv, the data field is not affect the following discussion. Therefore, only written from a 342-byte {410 if DOS 3 '>) buffe two data formats will be referred to— the DOS 3 2 r The 3.2 and 3.3/ProDOS sector formats are show format and the DOS 3.3/ProDOS format. n m Figure 9.15. Other than the three extra .secto An important point concerning Apple disk data there are several basic differences. The rs formats is that you can write any sort of bit stream address field Identifiers are different, D5 A A B5 in 3.2 and you desire, but you must write something that can D5 A A 96 in 3.3/ProDOS, causing bootstrap incom- be read by the logic state sequencer. The sequencer patibility between the two formats. The read sync- was designed to read a certain data format, and it's ing leaders are different as was mentioned DOS 3 '^ all it can do to read this floppy data reliably. Copy overwrites each track with 9984 FF86s before writ- protect artists must study the READ sequence very ing the sectors, but DOS 3.3 and ProDOS don't. DOS thoroughly to discover ways to write bit streams 3^2 reserves space for data by writing 431 FF32s which can be synced by the READ sequence with after each address field while formatting. DOS 33 some secret manipulation by a 6502 program. and ProDOS reserve space by actually writi We will see that the READ sequence will properly data field, with unwritten gaps of about 50 ng a MPU read streams of data written from the 3.2, 3.3. and cycles on either side. The gaps are too short to enabl e ProDOS write tables in 32-cyele loops. It does take accidental detection of a false data field identifica - an indefinite period of time for the sequencer to sync tion strmg .so they don't hurt anything. In either up when it first encounters a random stream of data. DOh 3.2 or DOS 3.3 processing, the data space However, random data streams in the DOS formats behind an address field is overwritten with a leader are always preceded by read syncing leaders which and data field when a "write sector" call to RWTS is force the READ sequence into sync very quickly. made. The .same is true of a "write block" call to These leaders consist of a series of 111111110 or DIIDD, but thedata space behind two address fields 1111111100 data streams. They are written by stor- is overwritten. ing $FF in the data register in 36-cycle loops An interesting point about DOS formats is the DE (UllUllO) or 40-cycle loops (lllllllIOO) before AA EB series that follows every address field and flowingdirectly into the 32-cycle data writing loops. data field. Apple has always had trouble writing the Writing data at intervals greater than 32 cycles EB. In RWTS 3.2 they cut off the EB at the end of results in trailing ZEROs (see WRITE sequence. the data field by neglecting to wait 32 cycles before State 2;39-SL0). This causes the ZEROs behind the switching READ/WRITE to READ after storing eight ONEs in the read syncing leaders. EB^ in the data register. They changed that in When a string of read pulses from a read syncmg RWTS 3.3, so the EB is actually written at the end of leader is applied to the sequencer, bytes of data the data field. However, RWTS 3.3 and the FILER following the seventh FF36 or fourth FF40 will formatting routine both cut off the EB at the end of always be in sync* RWTS 3.2 syncing leaders are the address field. Those cut-off EBs are not really series of FF36s. RWTS 3.2 uses more than seven, written, and no attempt to verify their presence is which works fine, but only seven are necessary. made in RWTS or DIIDD processing. RWTS 3.3 and DIIDD use FFs written in 40-cycie loops as read syncing leaders. A stringof four FF40s The READ Sequence followed by valid data will ensure that following There is an odd contrast in Apple Disk 11 I/O. The data will be in sync. The useof FF40s allows RWTS 6502 program works the tail off the MPU to write 3.3 and DIIDD to sync in a shorter period of time, data— initializing the WRITE sequence, then stor- slightly increasing the space available for data. ing coded data in precise timing loops. Yet, the There are two different times when data is writ- WRITE sequence listing is really pretty simple. ten toa disk. One time is when RWTS, FILER, or Reading is just the opposite. The MPU program sits other utility formats the disk, writing sector infor- back and lets the sequencer do all the work. The mation for16 (3,3/ProDOS) or 13 (3.2) sectors on 35 program merely polls the data register, waiting for tracks. The other time is when the data field for the sequencer to lay a complete byte at its feet. The a sector on a track is written. Writing a data field READ sequence is not simple. Our discussion will consists of positioning the head, then reading concentrate on the 3,3 sequencer, which is very tnespecified sector address field is found. Afteruntil nearly the same as the 3,2 sequencer. the We start by assuming that the sequencer is con- ^mSand PF40 refer to $FF bytes written using 36- or 40-cycle figured for reading ($C08E,X; ?;C()8C,X) and that a valid data field is passing across the READ/WRITE 9-28 Understanding the Apple lie DOS 3.2 FORHftTTED SECTOR NEXT DATA SPACE SECTOR SYNCING LEADER fiDDRESS FIELD 431 FFS ->-FF 16-80 FFS -»-FF FF D5 AA B5 VOL VOL TRK TRK SCT SCT SUM SDM DE AA EB 32 32 32 FF FF- FF FF- 36 36 36 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 SYNCING LEADER DATA FIELD KWTS 11 FFs -fr-FF SUM DE AA EB D5 AA AD 410 WORDS 32 32 14 COMHAND-2 ■ 36 FF- 36 36 CODED 5/3 32 DATA FF 32 32 32 LAST EB OF 3.2 DATA FIELD NOT COMPLETELY WRITTEN. DOS 3.3 / ProDOS FORMATTED SECTOR SYNCING LEADER ADDRESS FIELD DATA SPACE NEXT SECTOR 5-40 FFS 'FF FF 96 VOL VOL TRK TRK SCT SCT SUM SUM DE AA EB NULL 40 40 40 32 AA D5 32 32 32 32 32 32 32 32 32 32 32 16 50 DATA FIELD S2 GAP FF- 32 H GAP LAST EB OF 3,3/PcoDOS ADDRESS FIELD NOT COMPLETELY WRITTEN. SYNCING LEADER DATA FIELD 5 FFs RWTS COMHAND-2 — FF FF FF FF FF D5 AA AD 342 WORDS SUM DATA 40 40 40 40 36 32 32 32 DE AA EB FF CODED 6/8 32 32 32 32 14 [H NOTES: [T] Volume = $01 (SAA SAB in 4-4 code} on disks lormatted by FILER. d] Pre-Data gap is 49 cycles in disks formatted by FILER Post-Oata gap is 54 cycles in disks fortnalted by FILER. H] RWTS 3 3 Command 4/Ccmmanil 2 data field misalignment is approximately 60 cycles. FILER format/ DIIDD Command 2 data 1ield misalignment is approximately 16 cycles, [H Final SFF is cut ofl at 14 cycles wtien data field is written by RWTS 3.3 Command 2 or 4 or by /• mand 2 FILER lormatting routine. It is cut off at 22 cycles wtten ttie data field is written by DIIOD Com- Figure 9.1 5 Diskette Formatting. The Disk Controller 9-29 head with every eighth bit set. Further assume that long as possible so that the 6502 program can figure QA of the data register is not set, there is no read out it's good stuff. The read pulse shifts the sequencer pulse present, and the sequencer is at State 2. You've to State 2 of column 3 (08-NOP). Then the read pulse gotto start somewhere, and we are starting at State goes away and we sequence to column 4, State 0 2 of column 2 in the READ sequence listing of Fig- (18-NOP), then State 1 (38-NOP), then State 3 (48- ure 9.11. NOP), etc. We are sequencing now, waiting for the At this location in the sequencer there is a 38- read pulse that means the second MSB is a ONE or NOP. At State 3, there is a 48-NOP. At State 4, there the decision point that means the second MSB is a is a 58-NOP. We are sequencing through the states, ZERO. waiting for a read pulse. Assume a read pulse occurs We'll say a read pulse occurs at State 8. The at State 6, switchi ng the sequencer to column 1 . The sequencer goes to column 3, State 8 (D8-N0P), read pulse will last for one sequencer clock because column 4, State D (E8-N0P), State E (F8-N0P), it is synchronized to the clock by a pair of flip-flops State F (EO-CLR). The data register is finally and a NAND gate. There is a D8-N0P at State 6 in cleared. It was held from the last read pulse or column 1. In fact ifyou look at column l.aread pulse decision point of the previous word until past the at any of the states would have resulted in a BYTE FLAG pulse and second MSB pulse of this D8-N0P. word. The sequencer then goes to column 2, State E When the read pulse goes away after the next (FD-SLl), then to column 2, State F (4D-SL1). We clock, the sequencer goes to State D in column 2, a shift ONE twice, once for the BYTE FLAG and 08-NOP. This means move down to State 0 (18-NOP) once for the second MSB set, then flow to State 4 of and then up to State l(2D-SLl).ThisSHIFT LEFT column 2 in the exact condition in which we started: ONE is a direct consequence of the read pulse. A QA reset, sequencing along, waiting for a read read pulse occurred, so a ONE was shifted in. Assume the SLl does not cause QA to become set, Now we shift in six more bits of data which sets pulse. Q A and puts us at QA WAIT. You should notice that and don't get tired of assumptions. We now sequence to State 2 in column 2, right where we started, mov- QA is set precisely when a complete 8-bit word , lead ing down the line, waiting for a read pulse. by the BYTE FLAG, is completely shifted in. We This time let's say no read pulse occurs before we made an assumption earlier that we were in syne, reach State 9. This is the point at which the se- but no further assumptions were required. Once we quencer decides it can't wait for a ONE any more— are in sync with a continuous stream of MSB set thatwasaZERObit.State9isa29-SL0.AZEROis data, we stay in sync. shifted in. We'll say Q A is still not set and we're back We are at QA WAIT, waitingfor the BYTE FLAG to State 2, waiting for a read pulse. This cycle will pulse that starts the next word. Suppose somebody continue until QA becomes set after an SLO or SLl. had written the word we just read using a 3fi-cycle The sequencer is shifting in data based on the pres- loop instead of 32. There wou Id be a ZE RO following ence or absence of read pulses. the eight bits of data prior to the BYTE FLAG Now assume QA sets as the result of an SLO or pulse. You can't read ZEROs from QA WAIT. SLl. This breaks the loop, shifting flow to State 2 of There is no decision point here. The only thing the column four, a 28-NOP. We are at State 2; the next sequencer will respond to is a read pulse, so the state is State 2; we are going nowhere until a read ZERO passes right by and is not shifted to the data pulse occurs. This is the QA WAIT location, out- register. lined in both the 3.3 and 3.2 listings. If the se- Assume the next BYTE FLAG pulse occurs, this quencer isin syne with the data stream, the fact time followed by a ZERO. From QA WAIT the that QA is set means that a valid 8-bit word is sequencer takes the same path it did previously, now in the data register just as it was when it was except no read pulse occurs. The decision point is stored there to be written. We will assume for now reached at column 4, State C (AO-CLR) followed by that the sequencer is in sync with the data stream. column 2. State A (BD-SLl), State B (59-SLO). State This means that the next read pulse will be the MSB 5 (68-NOP), etc. The sequencer cleared the data set pulse of the next word. register, shifted a ONE, shifted a ZERO, then con- So we're sitting at QA WAIT waiting for the tinued processing of the next six bits. BYTE FLAGof the nextS-bitgroup. The read pulse The whole idea of the QA WAIT is this: the occurs. Do we clear the data register and do an SLl? sequencer always Itnows the next bit is a ONE so No way, Jose. That's a valid byte sitting in the data it is not monitoring the next pulse as data; it is register. We're going to hold that information as monitoring the next pulse as the BYTE FLAG. It ^ij 9^ Understanding the Apple lie In data written by RWTS or DIIDD, the monitors the pulse that follows the BYTE FLAG as se. quencer is never left to randomly sync on a data data, and after monitoring this second pulse, it stream. All data is preceded by read syncing leader clears the data register and shifts in a ONE,ZERO s which ensure that the sequencer is in sync when or a ONE, ONE. In the process, the valid data word following data is encountered. A string of seven or is held in the data register for a long time with the MSB set, a condition which a 6502 program can more FFs written in 36-cycIe loops or four or more easily detect. FFs written in 40-cycle loops will ensure synchroni- How does the sequencer get in sync with a data zation. These 9- and 10-bit write cycles cause syn- stream? The QA WAIT will cause the sequencer to chronization because they are longer than the 8-bit eventually sync on nearly any valid data stream it groups. When encountered, these strings quickly encounters. This is because it ignores ZEROs while are aligned into groups of eight ONEs followed by sitting at QA WAIT. What the READ sequence one or two ZEROs, Table 9.4 shows the worst case does is to give the MPU a look at the data stream conditions for syncing to strings of FF36s and in groups of eight bits. Every such group has a FF40s. leading ONE. ZEROs between a group and the In the RE ADsequence examples we went through, next ONE are lost. many events could have occurred which were not Suppose the sequencer encounters a stream of taken into account. It would not be practical or use- data which was written in 32-cycle loops with the ful to try to step through all possible events. Deeper MSB set on every 8-bit word. Being out of sync, the analysis shows that the read sequence is designed to sequencer groups the first data into eight bits lead correctly interpret read pulses while tolerating an by a ONE in some random way. This is illustrated in expected variation in the pulse interval. Figure 9.16 the first entry of Tkble 9.4, IXXXBXXX. The B is my attempt to put the basic flow of the 3.3 READ represents the BYTE FLAG pulse. It is a normal sequence in perspective in a simple diagram. The read pulse, like that generated by any other ONE, pertinent sequencer states are listed next to each but it is represented by B here for illustration. When block to aid readers in correlating the flowchart to the sequencer is in sync, the BYTE FLAG will be the sequencer listing. the first ONE of every group. In this flowchart, it was assumed that the read At the first entry of Table 9.4, the BYTE FLAG is pulse interface circuits were successful in produc- i n the fifth bit position from the left. If the bit foUow- ing a read pulse which was actually one clock period ing this group is a ONE , that ONE becomes the first in width. In the READ sequence, there are provi- bit of the next group, and the BYTE FLAG stays in sions to handle the rare event that a 2-clock read the fifth bit position. If, however, the bit following pulse occurs. This is an extra ounce of reliability this group is a ZERO, the ZERO is lost and the which would clutter up the flowchart and obstruct BYTE FLAG moves closer to the MSB of the next understanding of normal flow. I have monitored the group. Eventually, several ZEROs will have been read pulse with an oscilloscope and have never seen encountered between groups, and the BYTE FLAG any read pulses that were not properly synchronized will reach the MSB. From that point, the se- to the sequencer clock. quencer will stay in sync because the bit follow- Please direct your attention to the 8CP WAIT ing each group of eight will always be a ONE. decision block near the bottom of Figure 9.16. This Table 9 4 Syncing the Read Sequence to Data . SYNCING TO A RANDOM DATA STREAM SYNCING TO FF36S IXXXBXXX 10Blilll SYNCING TO FF408 1XXXBXXX0 110B1111 100B1111 IXXBXXXX 1110B111 11100B11 IXXBXXXX 11110B11 1111100B 1XXBXXXX00 111110B1 111111100 IBXXXXXX 1111110B B111111100 1BXXXXXX0 11111110 B111111100 BXXXXXXX B11111110 BXXXXXXX B11111110 idLpiS The Disk Controller 9^1 SECOND READ PULSE 4-12 CLOCKS AFTER FIRST 3CPN0P CLEAR QA SHIFT LEFT 1 SHIFT LEFT 1 QA' 1CP /-^ MOP SHIFT LEFT 0 BEAD PULSE QA' SHIFT LEFT 0 2CPN0P SHIFT LEFT 1 RESET QA? SET Figure 9.16 SimptWed Rowchart of the Read Sequence. 9-32 Understanding the Apple lie you can see that it shows what would happen wit! represents the time when the sequencer is sequenc- one data stream not used in any Apple DOS ing up column 2, waiting- for a read pulse. The 8CP (BlOOOl). This is sequencer performance, not driv( WAIT indicates that a ZERO will be shifted if a read and disk performance. The use of a string of thret pulse hasn't occurred by the eleventh sequencer ZEROs is not recommended, although a copy pro clock after a read pulse, and following- ZEROs will tect scheme might use such a string. be shifted every eight clocks after the first ZERO. As an example of interpreting Figure 9.18, inter- Thewrite interval iseightclocks. of course, so there is an allowable distortion of three clock pulses for val A is the case of a BYTE FLAG pulse followed bj a second MSB pulse. The expected interval between the first pulse position after a read pulse. This is the these two pulses is eight sequencer clocks. The 3.S main difference between the 3.2 sequence and the sequencer will read the second pulse correctly if il 3,3 sequence. After the first ZERO, following occu rs anywhere from 3 to 12 clocks after the BYTE ZEROs are shifted every 10 clocks in the 3.2 se- FLAG pulse. The 3.3 sequencer will read the second quence. This represents a skew away from the write pulse correctly if it occurs anywhere from 4 to 12 interval while reading^ strings of ZEROs. It makes no difference with the 3.2 data format, but it makes clocks after the BYTE FLAG pulse. reading less reliable with the 3.3/ProDOS format. The amount of time a valid data word is held in the The skew in the 3.2 READ sequence is shown in data register depends on the second MSB of the next Figure 9.17. While the 3.3 sequencer always makes word, normal pulse interval variations, and, in the a shift 0 decision on the third clock period past an 3,2 sequencer, the least significant bits of the word. expected pulse, the 3.2 sequencer starts making the The only bad thing that can happen is that the data decision at the wrong point after the first ZERO. will be valid for too short a period of time due to a There are never more than two ZEROs in a row in fast readingd rive, a slow writing drive, or both. The 3.3/ProDOS data, but the sequencer will handle average data valid period for some data streams is more than two if drive improvements make it a tabulated in Table 9.5. Values are in sequencer possibility. Note that the 3,2 sequencer will read clocks, so the number of M PU cycles is half as many. 3.3/ProDOS formatted data, especially if the read- In the Ikble 9.5 DATA STREAM entries, "B" ing drive is slightly slow. The 3.3 sequencer reads represents the BYTE FLAG pulse which follows the 3.3/ProDOS data more reliably though, valid data. As always, variations in disk surface If a read pulse occurs on the twelfth sequencer speed at the read/write head are most likely to cause clock after the previous read pulse, it is smack in the errors in the presence of one or two consecutive middle of the two points where the sequencer ZEROs, expects a pulse. Is this an early pulse caused by a The average data valid period must be at least 14 fast drive or a late pulse caused by a slow drive? The sequencer clocks if the MPU is to detect it in a sequencer treats this pulse as an early pulse when it normal 6502 polling loop. Notice that the 3,2 occurs, no doubt because it takes less room in the sequencer would have trouble meeting this require- sequencer ROM to do so. As a result, the sequencer ment on data which has two trailing ZEROs. This is tolerates a fast reading drive or a slow writing one more reason that a 3.2 sequencer would have an drive better than the opposite condition when read- easier time with 3.3/ProDOS formatted data if the ing the data format it was designed to read. reading drive■O were a little slow. For reference, I have tabulated the intervals The selection of D5 AA as the field identifier which the sequencer can tolerate for various types of in DOS 3.2, DOS 3.3, and ProDOS was no accident. written data. Figure 9.18 shows this tabulation, and D5 and AA both consist of alternating strings of READ READ READ READ PULSE PULSE PULSE PULSE READ 1 EXPECTED 1 EXPECTED I EXPECTED PULSE JL EXPECTED o ■H- o o DOS 3.3 DECISION POINT- DOS 3.2 DECISION POINT . Figure 9.1 7 Decision Points for Reading ZEROs. The Disk Controller 9-33 ■D r'^r^^ir -O 1l n. ii A ZL J1 n_ JL n R •o- k. BYTE FLAG DOS 3 2 13 DOS16 3.3 13 MIN AVG MAX MIN AUG MAX 19 3 168 12 4 8 12 12 16 19 15 125 8 11 21 5 11 22 20 27 19 2 248 31 11 21 4 8 24 31 12 20 24 24 22 12 16 21 16 27 22 31 28 20 27 32 32 41 32 35 24 24 ALL VALUES IN SEQUENCER CLOCK PERIODS Figure 9.18 Read Performance of the Logic State Sequencer. ONEs and ZEROs, afact which g-ives them a unique E A 96 BX can be Krotiped as A A B.'S if the sequencer identity in an en vironment f 11 led with stri ngs of F Fs is out of sync: and other valid DOS data. Even when it is not in sync, the sequencer should never accidentally pro- Xll. 101010100 .101 10101 -X duce the D5 AA combination from a valid data It is my speculation that this is the reason the stream. This is because the 11010101 10101010, address identifier was changred to 05 A A 96 in DOS 11010101010101010, and 110101010010101010 com- 3.3, causing the DOS 3.3 controller to be unable to binations do not exist in a valid data stream. boot 3.2 disks. It is my further speculation that this Obviously, if D5 A A should not be accidentally read, is why DOS 3.3data words all have at least one pair then the D5 AA AD, D5 AA B5, and D5 AA 96 conibinations should not be accidentally read either. of adjacent ONEs in bits 0 throujfh 6. This elimi- nates longer strings of ONEs alternating with Reliability is even greater because the AA AD com- ZEROs which might tend to be interpreted as field bination itself should not be accidentally produced identifiers in an unstable read pulse environment. by DOS 3.2, DOS 3.3, or ProDOS data. In particular, the data EA A5 9X or EA A5 AX or n ^A B5 combination should not be aceiden- EA A5 BX could be grouped as AA 96 if the use of «ily produced by DOS 3.2 data, but it can be pro- A 5 were allowed: duced byan out-of-sync encounter with DOS 3.3 or i'roDOSdata. Specifically, the strings EA 96 AX or XI 1.101ClfeJ10. 10010110.x 9-^ Understanding the Apple He Table 9J5 Data Valid Periods in Sequencer Clocks. PERIOD 3.3 AVERAGE VALID PERI DATA STREAM 3.2 AVERAGE VALID 16 18 16 XXIBI X10B1 16 100B1 14 16 XX1B0 19 17 X10B0 17 17 100B0 15 17 The switch from B5 to 96 as an address field iden- an example, the following Applesoft subroutine will tifier inDOS 3.3 may have been required to main- tell you if a disk in Slot 6, Drive 1 is write protected; tain the normal level of reliability in Apple Disk II 10 SLOTS = 49376 : REM $C0E0 I/O. I hope it was worth the cost of bootstrap incom- 20 DRIVEl = PEEK (SL0T6 + 10) patibility between DOS 3.2 and DOS 3.3. If so, my apologies to Apple for sug:gesting they could have 3B REED = PEEK (SL0T6 -I- 14) done better to stick with D5 AA B5 as the address 40 DRIVESTART = PEEK (SL0T6 + 9) field identifier. 50 LODE = PEEK (SL0T6 -I- 13) 6kJ WPROTECT = PEEK (SL0T6 + 8) The Read Sequence as a 70 REM LINE 50 GETS DATA REGIS- Finite State Automaton TER AND TURNS DRIVE OFF A reviewer of a rough draft of Undemtavdivg the 80 IF WPROTECT > 127 THEN PRINT Apple II. engineer/programmer Jim Aalto, used the "WRITE PROTECTED" Figure 9.11 listing of the DOS 3.3 read sequence to 90 IF WPROTECT < 128 THEN PRINT construct his own illustrative tool for studying- the "NOT WRITE PROTECTED" read sequence. This tool is valuable enough that we 100 RETURN decided to include it in that book as well as this one Note that no DOS need be resident for this program (see Figure 9.19). Jim depicts the read sequence as a to work. It bypasses the DOS and goes straight to the "finite state automaton." Like a flowchart, Figure controller. 9.19 shows the logical paths the sequencer may take, More sophisticated programs may make direct but the flow is in step with the sequencer clocks use of DOS subroutines to perform special func- pictured at the top. The average read pulse interval tions. You do not have to be an expert on DOS 3.3 or is also pictured, so sequencer performance with ProDOS to do this in your programs. DOS Pro- pulses arriving at various intervals is clearly illus- grammer'f! Manual for II, II+, lie shows you how to trated. Itis recommended that readers studying read a sector, write a sector, position the head to a this figure attempt to relate it to the read sequence track, or format a disk by making calls to RWTS. listingof Figure 9.11. ProDOS Technical Reference Manual (for the Appk II family) shows you how to read and write ProDOS PROGRAMMING EXAMPLES data blocks by making direct calls to DIIDD. It is FROM RWrS also possible to make direct calls to the higher level file handlers, the DOS 3.2/3.3 file managers and the There are several levels at which you can program ProDOS MLI (Machi ne Language Interface). Infor- disk I/O. The Apple disk operating systems are set mation concerning the calling of these handlers is up with very versatile file handling capabilities contained in the "beneath" books, Beneath Apple which can be utilized from BASIC as shown in the DOS and Beneath Apple ProDOShy Don Worth and Apple manuals, DOS Proqramwer's Manual for II, Pieter Lechner.* II+. He and BA SIC Programming With ProDOS. If *Beneatli Apple DOS, Quality Software, 1982; Beneath Appk one had a desire, he could also perform such direct ProDOS, Qual ity Software, 1984. These books cover considerably control functions as turning drives on and off, select- more subjects than those mentioned here and are recommended ing drive 1 or 2, positioning the head, checking for reading for any student of Apple disk I/O. ProDOS Tichnwal Reference Marmal also contains information on callinj: the MU write protection, and checking to see if a drive is turned on from BASIC via PEEK instructions. As and othermended reading. programming tasks related to ProDOS and is recom- ;fi0^ •^ The Disk Controller 9-35 ^- I- ■? CJ < co 111 no m"* 3 u u:> IT < LU en Cl. 5 CE m t_ to LU en O S "J I-^ " Z _i < n- ^ f-- g < z cc h- -J £ o a LU o o !3 UJ ^ LO O lified ($F8D7), and reading an incorrect track Apple's purpose in eliminating the 256-byte inter- mediate buffer in DIIDD was not to save space. It number residts in an attempt to step to the desired was, rather, to save the time it takes, in prenibbliza- track from the located track ($F8C8). Also, after tion, to strip off the two LSBs and store the 256 reading a data field, there is no call to a "postnibbli- XXXXXXOO words in the intermediate buffer. zation" subroutine. Packing the two LSBs of 256 bytes into 86 The simplified sector check and absence of a XXXXXXOO words in the auxiliary buffer still volume check after address field reading result in takes a lot of time, but the code that does this reduction of the delay between Command 2 address field reading and data field writing from about 123 ($FDFO— $FE43) is optimized for speed so PRE- NIBBLIZE execution time is minimized. cycles in RWTS to about 78 cycles in DIIDD. This, in A lot of complicated code was devised just to speed turn, reduces the misalignment between data fields up prenibblization, but this goal was nicely achieved written during formatting and data fields written via Command 2 from about 60 cycles in RWTS to *The ProDOS speed improvement also stems from the fact that about 16 cycles in DIIDD. Since there is a 54-cycIe one call to DIIDD results in two sector accesses, from sector gap trai Iing the data field and the speed tolerance of interleaving designed to take advantage of DIIDD improve- ProDOS is so tight, the DIIDD Command 2 data ments, and from streamlined MLI file handling including a "direct read" mode that transfers file read data directly from a field should not partially overwrite the read syncing disk to itsfile memory buffer. destination without first transferring it to a leader of the following address field. ProDOS The Disk Controller 945 since DIIDD prenibblization takes only about 6,450 combined XXXXXXXX data which is stored to the eyetes as opposed to about 10,950 cycles in RWTS. 256-byte buffer is true 8-bit data, just as it resided in The savings of 4,500 cycles represents more than one a 256-byte buffer before it was stored on disk by a Command 2 call to DIIDD. third of a sector (one sector passes the drive head in- about 12,750 cycles). To put it another way, with Because of the extra processing that takes place every other sector interleaving, ProDOS can use between readingofdisk data words, DIIDD reading about 5800 cycles (12750 - 6450 - 500 cycles for loops take longer than RWTS reading loops. As slow DIIDD head positioning) of processing time opposed to the 26-cycle reading loops of RWTS, the between Command 2 calls to DIIDD. If DIIDD pre- reading loops of DIIDD take 26 (auxiliary buffer), nibblization took 10,950 cycles, ProDOS would be 29 (bottom, middle thirds), or 28 (top third) cycles. able to use only about 1300 cycles between Com- This means that DIIDD will not tolerate as fast a mand 2DIIDD calls. reading drive {or slow a writing drive) as RWTS will, and it indicates why the FILER formatting Apple was able to achieve an even better perfor- routine has such tight specifications on the length of mance improvement in Command 1 DIIDD process- ing. Whereas postnibblization in RWTS takes the address field read syncing leader and, conse- about 10,250 cycles and occurs entirely after the quently, ondrive speed. data has been read from disk, postnibblization in There is a particularly tight spot between reading DIIDD is performed on the fly {while the data is the bottom third and middle third of the 256-byte being read) and adds no processing time to Com- buffer where there are 30 cycles between data regis- mand 1DIIDD calls. In other words, ProDOS can ter polling {$FC75— $FC88). I believe that this sin- process data for up to 12,750 cycles between Com- gle instruction sequence determines the drive speed mand 1DIIDD calls, and still pick up the next block variation which DIIDD will tolerate since it is the without waiting for a complete disk revolution. weak link in the chain. Given that data is written in The READ DATA FIELD subroutine, which is 32-cycle loops and that the disk data word should be called after the address field for a specified sector held valid in the data register for one cycle more has been read, begins at $FBFD. At entry to thi.s than a 7-cycle polling loop (see Tkble 9.5). the 30- subroutine, the read syncing leader preceding the cycle period between reads means that there can be datafield willbe passing the drive head, so there is no more than 3 parts in 32 variation in speed some time for processing before the $D5 $AA $AD between the reading and writing drives. In other datafield identifier is expected. This time is utilized words, drive speed variation plus speed variation to modify some instruction operands in the subrou- due to disk flutter must be less than plus or minus tine so disk data can be read via "LDX $C0nC" 4.7% or occasional reading errors will occur at the instead of "LDA $C08C,X" as is required by the bottom/middle border in a data field. reading scheme, and so the bottom third ($FC6F), I believe that Apple could make this speed toler- middle third ($FC96), and top third ($FCAE) of the ence less critical with some minor modifications to 256-byte buffer can be accessed via "STA $nnnn, Y", DIIDD. The modification would center around mov- thus native.saving a cycle over the "STA (ZP),Y" alter- ing the auxiliary buffer from $FB00-$FB55 to $FBAA— $FBFF. This would change the instruc- After the pre-read processing, the data field iden- tion at SFC7A from "LDX .fFA56,Y" to "LDX tifier isread ($FC31), a running checksum is initial- $FB00,Y"and, because the Y-indexing would not be ized {$FC55), and 86 disk words are read ($FC59), across a page boundary, reduce the 30-cycie delay to decoded to XXXXXXOO format ($FC5E), and stored 29 cycles. The change would require the retuningof in the auxiliary buffer ($FC61). the writing loop at $FD3A— $FD4E. but this could easily be accomplished by getting slot number via Next, the bottom third ($FC69— $FC83). middle absolute addressing at $FD44. Additionally, all third ($FC84-$FC9A), and top third {$FC9C- *PCB7) of the 256-byte buffer are read from disk code from $FBFD on would have to be moved back and decoded to XXXXXXOO format, then ORed three memory locations. No problem, right? I hope with OOOOOOXX data which is postnibblized on the not. The person who wrote this code was so good that flyfromtheauxiliary buffer XXXXXXOOdata. The it scares me to second guess him in print. Nonethe- less, maybe he missed just one little trick. 946 Understanding the Apple lie HARDWARE APPLICATION INSTALLING A WRITE PROTECT SWITCH ON THE DISK II DRIVE Did you ever want to store information on a write reasons, writing on special diskettes that have no notch , and writi ng on the backs of s ingle sided disks protected diskette? This involves removing the write if you do that sort of thing. If you happen to be a protect tab or cutting a write protect notch, writing the file, then sticking on a new write protect tab. software publisher, this mod is a must. The ideaof the write protect switch is not my own. Here's another one. Did you ever delete a file, then It was pointed out to me that the modification had immediately regret it? If you haven't run into one of been suggested in magazine articles. Once it is real- these situations, then I'll only say that your ball sure ized that such a modification is possible, the design bounces more nicely than mine does. This applica- tion note details a simple modification to the Disk II of the modification is fairly obvious. drive which enables you to write on write protected Figure 9.21 shows the modification. What is disks and al.so gives you time to have second thoughts involved is installation of the new switch and rewir- about writing files to or deleting files from a disk. ing of the already present switch which is activated The modification involves installing a single by the write protect notch. The type of switch switch on the front of the Disk II drive. The 3- required is a ON-OFF-ON SPOT (Single Pole, position switch allows selection between normal Double Throw) switch. The installation procedure operation, forced write protection, or bypass of given here involves installing it on the front of the write protection. Ifyounormally leave the switch in drive, but you may prefer to put the switch on a the protect position, you will always have to take an remote box. When buying the switch, select one that extra step to write, delete or rename a file. This is a switches very easily so a minimum of stress is placed fairly normal feature of expensive storage periph- on the plastic front panel of the drive. Since the erals associated with mainframe computers. Nor- notch activated switch is mounted below the disk mally, taking the extra step required to overwrite slot, the new switch should also be mounted below data makes the operator think twice about possible the slot so wires will not interfere with disk inser- destruction of important data. tion. Choose a mounting point near a reinforcing The bypass position of the switch allows you to structure on the back of the front panel to give added write on a protected disk. This might be of use in strength to your installation. All wiring should be writing on disks you have protected for your own soldered, and 24-gauge insulated wire works nicely. -T^ 5V PROTECT IK PHASE 1 •IK WRITE ENABLE CONTROL PROTECT NORMAL 5V WPT BYPASS WRITE ..«r.,r,rn PHASE 1 - CONTROL I Yen NORMAL • PROTECT ■* PROTECT MODIFIED V Notch in side of disk Figure92'! ASingleSwilchonlheFrontofmeDriveAllowstheUsertoSelectNormal. Forced Write Protect, or Bypass Write Protect. ■■^'. The Disk Controlier 9-47 The purpose of steps 5,7. and II is to improve acces- panel to the side, attempting not to strain sibility, andyou may elect not to perform them if you wires connected to the IN USE indicator. the are good at working in tig-ht spaces. 7. Use a fine lead pencil to outline the position of Instaitation Procedure;* the notch activated switch. This way vou can remstall it in the same position. It will also help 1. Turn off the computer and remove the con- to slide a disk in and out of the drive while troller from its slot. Mark pin 1 of the 20-pin observe the switch action, so you will be ableyouto ribbon cable connector and plug; with fingernail reproduce the same action at reinstallation. polish so you will not reinstall the cable incor- Remove the two alien screws which hold the rectly. Disconnect the ribbon cable from the switch to the side of the drive. controller and move the drive to a convenient work area. 8. A black wire is connected to the normally closed contact of the notch activated switch. Desolder 2. Remove the four screws from the bottom of the the black wire. This wire needs to be connected drive. Remove the white case by holding the drive on your palm and sliding the case to the to the ON-OFF-ON switch and it will probably rear. require a short splice. Spiice a short jumper 3. The notch activated switch can be seen toward between the black wire and the center or com- mon contact of the ON-OFF-ON switch. Solder the front on the left side of the drive. Select the both connections and insulate the splice connec- location of your ON-OFF-ON switch so that tion with electrical tape or bv another suitable wirescanbeeonnected between the two switches method. in a way that drive mechanisms are not inter- fered with. Hold the switch near the selected 9. Connect a wire between the rfesoklered termi- spot to make sure no problems will arise. The nal ofthe notch activated switch and the NOR- location shown in Figure 9.22 works wel 1 with a MALmodecontactofyour ON-OFF-ON switch. small bodied switch. If you choose to have NORMAL mode in the 4. Mark and drill a hole for your switch. Clean out down position, then the upper contact will be the any plastic filings which fall into the drive. NORMAL mode contact, and vice versa. 5. The big horizontally mounted card is the analog 10. A brown wire is connected to the common eon- card. You may remove it by disconnecting the tact of the notch activated switch, Solder one two plugs at the back and by removing the 4-pin end of a, jumper wire to the same contact as the read/write head plug. Remove the retaining brown wire. Solder the other end to the BYPASS screw on either side, and the analog card slides mode contact of your ON-OFF-ON switch. The out. You may wish to clean the head with alcohol BYPASS mode contact will be opposite the and cotton swabs at this point. NORM.A.L mode contact. 6. Remove the two beveled head machine screws 11. Remount the notch activated switch to the side from each side of the front panel. Position the of the drive, aligning it to the outline ,vou drew with a pencil. Slide a disk in and verify that the switch clicks on and off as the disk notch is engaged and disengaged. 12. Mount the ON-OFF-ON switch to the front 13. panel. Reinstall the front panel on the drive, making sure the spindle engagement mechanism mates with the grooves on the hinged door on the front 14- The remainder of reinstallation is the reverseof panel. the dismantling steps. You can easily verify operation by attemptingto delete some test files and observing the write protect indication. Do not operate with any disk containing important files until you have verified correct operation of the modified drive. Figure 9,22 *P1easereari the NOTE OF CAUTION at the hetrinninRof the A Drive With the Writ© Protect Switch Installed. book before makiriE aTi.v mofiifieatiim to.vnur harrJware. 946 Understanding the Apple He You should mark the functions of the new switch tion with a new ON-OFP-ON switch should possible on most or all such drives. 1 happen toalso be own a on the front panel. I used white dry transfer letters FOURTH DIMENSION drive manufactured by (available in electronic stores) far this purpose. Siemens. I added the write protect switch mod to it Afterwards, I sprayed the switch area with an by splicing into the wires going to the photo switch. acrylic coating (also available in electronic stores) to On the 4D drive, the photo switch is mounted over protect the lettering. All drive openings should be the disk slot. The white wire is the input to the photo covered when spraying with acrylic coating to pre- switch and is the equivalent of the brown wire in the vent accidental coating of the read/write head. Some alternate source drives for the Apple use a above procedure. The yellow wire is the output of the photo switch and is the equivalent of the black wire light emitter and photo switch to check for write in the above procedure. protection. Rewiring the photo switch in conjunc- ;'a-j?^Sif chapter 10 Maintenance and Care of the Apple lie \ / ^ «. \ 4 i ->£ ^;, & The modern mierocomputer is such a marveious occurrence, because d igita! electronic circuitry is so thing. Just think of the accumulated knowledge and reliable. Yet, hardware failures do occur, and most industrial capabilityofthe human race represented of us encounter them eventually in our home or busi- by such a machine. Invented by man, feared by man. ness system. In this chapter, attention wiil be given exploited by man, and hated by man. Especially to the maintenance philosophy of the Apple He com- hated by man when it doesn't work right. After puter. There will besomediscussionof whatoptions years of having computer systems subjecting- us to you have when your system fails, and of some simple impersonal and illogical errors, we have advanced fault isolation steps which can be taken by you in to the point where we have computer systems in our yourhome. We also will discuss ways of reducing the own homes subjecting us to personal and illogical errors. probability of hardware failure in your system. The vast majority of computer mistakes are caused by imperfect programs. The more involved a APPLE HARDWARE RELIABILITY program, the greater the chance of an oversight by the programmer. We used to curse the computers. There is noelectronie circuitry more reliable than Now, when a husband writes a program that allows nis wife to enter her kitchen recipes, then destroys modern digital electronic circuitry. Digital ICs rou- them in milliseconds, it's not the computer that gets tinely operate for thousands of hours without fail- ure, and they are easy to replace if they do fail. The cursed. Yes, today's computers are very personal. Occasionally, computer malfunctions will actu- Apple computer is consequently a very reliable machine. There are, however, less reliable facets of ally becaused by a hardware failure rather than a program in disarray. This should be a fairly rare a computer than the ICs that popu late it. Some weak links in the reliability chain are discussed here. 10-2 Understanding the Apple He the Apple, a tinkering owner who installs anc Tinkering Users removes cards while power is applied. If you are very involved with your hardware, try- One of the worst things that can happen whilt ing new and different things all the time, you are installing or removing a peripheral card is that flex bound to make some mistakes which cause hard ing the motherboard might cause a hairline frac- ware casualties. People who like to tinker with their ture ofa current trace or solder joint. Of course tht computer should do so, because it's as fun as all get same thing could happen ifyoudrop your Apple or il out. Those same people would be naive to think they a manufacturing defect starts to show symptoms may not occasionally mess something up. Even The resulting marginal electrical contact can cause though my wife thinks otherwise, I have probably set no records in this area. I do, however, consider system problems to come and go in a random wa> based on such variables as temperature, mother- myself an Apple clobberer of the first degree. The board stress, and the price of hogs in Kansas City. A personality traits necessary to reach this plateau of good computer technician might be able to isolate a destructive potential are an infantile curiosity and problem like this on a good day if.you can afford the terminal absentmindedness. The possibility of causing hardware failure by wages of a good technician for a whole day. A reinforcing bar mounted at the back of the tinkering leads to the following common sense rule. Apple He reduces motherboard flexing to the point If your Apple is your bread and butter— if it costs where occasional card insertion and removal is not you money when it's not running— don't mess with likely to overly stress the motherboard. Even with it. If your Apple is your creative outlet, then play with your toy any way you please. the reinforcing bar, however, the mechanical integ- rity of the motherboard mounting is marginal. Per- sons who regularly remove and insert peripheral The Peripheral Slots and Auxiliary Slot cards should, therefore, not be surprised if problems It is this author's opinion that the most important related to mechanical stress eventually arise. Such hardware feature contributing to the Apple's mar- problems are much more likely if an auxiliary card keting success is the concept of peripheral slots, is removed and installed regularly, because the mounted on the motherboard with address decoded mounting near the auxiliary slot is extremely flimsy. control signals generated on the motherboard. The peripheral slots do represent a reliability weak point though. Suppose you had a television which Peripherals with Moving Ports allowed the owner to enhance it in all sorts of ways Moving parts are a reliability problem in any by lifting the Hd on the television and installing industrial creation. Compare an automobile to a cards in slots on a big motherboard. Surely, every computer. The automobile might run 100,000 miles owner who reconfigured his television a lot would before i1;s effective life is over. This will be 5000 mess it up eventually, and the TV repair industry operating hours at 20 miles per hour with many would be happy with the extra business. parts replaced along the way. Yet you could turn on The sort of thing that can go wrong when pulling your Apple and let it run for 208 days in a row (5000 or removing cards is that a card might get installed hours) and have a very reasonable chance of expe- back wards. I've only done this twice. It tends to wipe riencing nohardware failure. If a part fails, you can out one or more chips on the card. As soon as a chip replace it and go another few thousand hours with- shorts a power supply voltage to ground, the power out afailure. The main limiting factor on effective supply shuts itself off and damage to further chips is life is obsolescence. prevented. Now take a disk drive, an electro-mechanical An impatient owner might remove or install a card with power applied to the Apple. You can usu- device with precise mechanical alignment. Don't expect to run a disk drive for 208 solid days without ally get away with this, but when you see a spark, hardware failure. Friction can cause the motors or cross your fingers. I've never burned up more than head assembly to wear out, and like the front end one chip at a time doing this, but it's possible to "wipe alignment of a car, drive alignment sometimes goes out every chip connected to DO of the data bus. This out. Cleanliness becomes a factor. If you are really is because DO is adjacent to +12 volts on the periph- putting a lot of hours on your Apple, then you should eral slot pins and they may get shorted together. expect to eventually have to have some disk drive Combining two reliability hazards, you come up with the most common cause of hardware failure in maintenance performed. The same is true of a print- er. Heavy usage results in wear on the moving parts Maintenance and Care of the Apple He 10-3 and in probable eventual maintenance require- dentally dropped inside. Don't set coffee or ments. This is why printer manufacturers advertise sodas on the Apple, because you may spill them. how few moving parts are in their products. 4. Don't operate the Apple on an unstable power source. Be wary of operating during electrical The Power Supply storms because power may fail. In the hypothetical 208-day reliability test that 5. Connect power to the Apple through a bus bar or was mentioned earlier, if any unit failed, it would other device with a switch on it and turn the most likely be the power supply. This is because the Apple on and off using this switch to save wear electric currents in the power supply are so much on the power supply switch. The bus bar may greaterthaninanylC. Of course the powersupply is have current surge suppressors built-in which rated to handle a lot of current, but high current help stabilize the power applied. devices are usually more apt to fail than low current 6. You may elect to reduce the operating tempera- devices. Also, if the AC line voltage fluctuates, the ture ofthe Apple by mounting a fan on the case. power supply is the unit most likely to be damaged by the resulting current surges. Products are available which perform the three Application and removal of power to the Apple tasks of providing an external switch, surge sup- can be thought of as a control led fluctuation . The ICs pression, and temperature reduction. None of these is necessary for operation of the Apple, but it can be and power supply are designed to handle the cur- rent surge that occurs when the switch is turned on. argued that each one could improve its reliability. Still, there is no time when your computer is more Necessity of temperature reduction is the most likely to fail than when the power is fluctuating, questionable. The Apple uses commercial grade (as including when you turn the power switch on. This opposed to military grade) components which are means you should turn the Apple off if power starts guaranteed to operate within specifications over the fluctuating, as when the lights in the house go dim 0—70 degrees Centigrade (82—158 degrees Fahr- during a storm. It also means that you should not enheit) operating range. My measurements of the needlessly turn the power to the Apple off and on. Apple He operating temperature indicate that it is A particular reliability problem with the Apple under l.SO degrees Fahrenheit just above the 6502, which is the hottest spot I couid find. This is we!l power supply is the power switch. The switch arcs sometimes at power up, and this can eventually within the 158-degree specification of the compo- cause the switch to malfunction. Amazingly, this nents. Reducing this operating temperature should problem has been ignored for years by Apple, even still reduce thermal expansion, reduce the possibil- ity of malfunctioning of components that are not up though the rest of the world acknowledges its exis- tence byusing an external switch to turn the Apple to specifications, and reduce the possibility of mal- on and off. The part is a turkey, and it should have functioning due to overloading of signals by too been replaced by now in the Apple lie power supply many peripheral stotcards. Also, by reducing power design with one that will last. supply temperature, one would expect to increase the amount of current that can be supplied before overheating and failure of power supply compo- IMPROVING YOUR APPLE'S RELIABILITY nents occurs. To see for myself the effect of using a fan on the The reliability weak links give some hints on how to improve the reliability of your own Apple: operating temperature of the Apple lie, I ran a 4-hour test, measuring the temperature at the top of 1. Above ail else, never remove or install periph- the power supply and just above the MPU with and eral cards, the auxi 1 iary card , or ICs w ith power without a fan running. The test is patterned after a applied. similar test I performed on an Apple II for Under- 2. To improve reliability, don't tinker with the siandrnffthe Apple 11. The fan used was a Super Fan Apple or peripherals. This must be each per- II made for the Apple by R. H. Electronics. It hangs son's compromise between the conflicting de- from the left side of the case and has an external sires of wanting a reliable computer and on/off switch and surge suppression. Four periph- wanting to tinker. You probably know that my eral cards were installed in the Apple under test, personal choice is to tinker all I want. which was a Revision B Apple He. The temperature 3. Keep the Apple covered when not in use so that measuring device was a pyrometer which utilizes a the electronics stay clean and nothing is acci- thermocouple for a probe. "^iis.. „ 104 Understanding the Apple He The results of the test are shown in the graph in in component heat dissipation wjU occur. Whether Figure 10.1. As the graph indicates, it gets very or not this is worth the price of a fan is a subjectiv^ warm near the surface of the MPU. Also, the fan matter. reduces the operating temperature by about 10—15 degrees Fahrenheit. Please note that the graph is REPAIR OF THE APPLE Me probably a good indication of the relative tempera- tures with the fan off and on, but that there are Repair of a broken digital computer is different many variables which affect the absolute reading, than repair of other sorts of electronic equipment. including the temperatureof the room, probe place- Many uncertainties of electronic circuit operation ment, and instrument accuracy. Additionally, the do not exist in digital equipment, because most of test does not measure the amount of improved com- ponent heat dissipation due to forced air movement the circuitry is made up of 2-state electronic in the cabinet. The measurements made at the sur- switches. In most circuit elements, either current face ofthe power supply were probably closest to the flows or it doesn't flow. This is a simple condition ambient air temperature in an Apple lie. It would compared to the infinite variety of signal conditions be fairly accurate to say that the ambient air which exist in analog electronics. temperature in the Apple He cabinet is about 25 The complexity of digital equipment lies not in degrees F. greater than room temperature, that the complex electronics but in complex logical capabili- temperature differential can be reduced by about 15 ties. As a result, any difficulty in the repair task will degrees F. with a fan, and that some improvement often be due to logical complexity. This is good, TEMPERATURE IN DEGREES F 120 -r Cover removed 1rom Apple lie End test Moved temperature probe to a point 2 mm above MPU. Tempera- ture indication drops while mov- ng probe. STARTED TEST BY TURNING AP- 80 - - PLE lie ON. FAM OFF TEMPERA- TURE PROBE AT -h-h TOP OF POWER SUPPLY. ■I I I I I I I I— I -+■ 60 I I I I-+- 180 120 -I—MOI TIME MINUTES 240 I !■ I IN Figure 10.1 Temperature Measurements Inside an Apple lie. Maintenance and Care of the Apple He 10^ because it means many hardware functions in a When a problem is beyond the capability of a computer can be verified, and many casualties can dealership or the repair of a problem will be so time be isolated by self diagnostic programs. More trou- consuming that it will not be cost effective for the blesome problems can be diagnosed by external dealer or customer, the dealer will swap out a major computers designed and programmed to trouble- assembly such as a motherboard or power supply for shoot certain classes of problems. Since computer a very reasonable cost. He then sends your repair- casualties are often logical malfunctions, what bet- able assembly to an Apple Level II repair facility. ter way is there to solve them than by logical analy- Apple can repair the assembly more easily because sis using a computer? they have sophisticated test fixtures, documenta- The Apple lie has a modest end user self-diagnos- tion, and assets not found in a computer dealership. tic capability consisting of motherboard firmware Other companies besides Apple will also have a turn routines that check motherboard RAM, ROM, and around policy on their Apple compatible products. lOU and MMU flag manipulation and reading. Therefore, when a peripheral card fails, you may However, these firmware diagnostics are somawhat well be able to get a quick swap at a computer limited in value since the Apple must be pretty dealership. healthy before they can even be executed. There is Apple will not allow Level I repair shops to per- no hardware or firmware based timing or video form some tasks. They maintain this control by re- signal verification, although auxiliary cards which fusing toswap assemblies upon which unauthorized perform these tasks must certainly exist in Apple's work has been performed. For example, a FjCvcI 1 checkout and repair facilities. RAM based diagnos- shop can change the analog card in a disk drive, but tic programs are available on disks to computer they can't change the drive motor. Also, with few dealers but are not available to owners. There is, therefore, very little an owner can do by way of exceptions, Apple won't accept a modified assem- bly. Apple's no swap rule for modified assemblies is isolating difficult casualties unless there is an in- fairly reasonable considering that they must make house computer technician with some test equip- their own repair operation cost effective. ment. There are some checks that can be made by The primary hardware based self diagnostic fea- anybody, but more on that later. tures of the Apple lie are the peripheral slots and The typical computer retailer will have what the auxiliary slot. An empty slot becomes a diagnos- Apple calls a Level I repair capability. They will tic port when you plug a specially designed lest often have a shop and a computer technician. They fixture into it. There can be no doubt that Afjple will also have a diagnostic peripheral card that is must use such test fixtures for production check out made by Apple, several disks full of diagnostic pro- as well as fault isolation, because they are an obvious grams, and a parts and information pipeline to necessity. From a peripheral slot, you can verify Apple. The diagnostic peripheral card contains power supply voltages, verify some timing signals, firmware to check the operation of several areas check RAM, ROM, the MMU. the lOU. and all including RAM, ROM, the keyboard, and the video address bus command features via DMA. measure display. If their disk-based diagnostics will load, for shorts at all pins, exercise the 6502 with a test they will verify and isolate faults in any peripherals program via the INHIBIT' line, and verify correct for which they have diagnostics. The technician or interrupt response. From the auxiliary slot, you can salesman can then replace components that are monitor timing, video generation, and memory indicated to be bad and hopefully fix the malfunc- management signals, and inject substitute timing tioning Apple very cheaply. The dealers also have signals or a substitute picture signal. Many prob- disk drive alignment disks and procedures which lems with individual ICs can be isolated to the chip allow their technicians to precisely align the Disk II while other problems may be isolated only to an drive and some drives that are compatible with the area. Further isolation of problems can be per- Disk II, formed by attaching jumpers from smart peri- Dealerships with more sophisticated repair capa- pheral or auxiliary slot test fixtures to various ICs. bilities will also work on some products for which Apple probably has an area full of engineers who do they have no advanced diagnostic aids, such as print- nothing but design test fixtures for Apple products, ers or modems. If there is a resident Apple techni- program them, and write test procedures for them. cian with an oscilloscope, he probably will repair We pay for this diagnostic capability when we buy many problems not pointed out or isolated by the diagnostic aids. Apple products, even though it isn't built into the Apple He. Large scale automated checkout and ' »"^^l!fe 10-6 Understanding the Apple He There are hazardous voltages inside the App], fault isolation of a product is the only way to provide but they are all in the power supply. Nevertheless, quality assurance and service a complex Money mass pro- is a good idea to pull the plug on the Apple anytim duction device in a cost effective way. for you are working inside. Never work on the powe developing this capabilitymustcome from sales and supply with the line cord attached. Many of th service revenues. power supply components are not isolated from th line voltage and there are numerous dangerous voli WHEN YOUR APPLE BREAKS age points in the power supply. When your Apple breaks, chances are that you will have to take it to a computer dealer for repair. The Firmware Diagnostics Yet, there are .some very simple checks you can The firmware diagnostics at $C400— $C7PF* pre make which might get your Apple up in a hurry. vide the Apple He end user with a modest capability These are checks which can be made by anyone, and for verifying correct hardware operation. They ab they are the kind of checks a salesman might make if are designed to indicate bad RAM chips, bad ROl you brought your Apple in on the service techni- chips, and MMUs or lOUs whose soft switches don' cian's day off. Be aware that any damage you operate correctly, but because of poor overall con cause while making these checks will void your cept, it is unlikely that the firmware diagnostics wil warranty if it is still in effect and make out of correctly indicate a bad ROM or RAM chip. Thi warranty repairs more expensive. Also, any use reason for this is that the diagnostics will not run i oftestequipment by unauthorized service personnel there is a completely bad ROM or RAM chip. might put your warranty in jeopardy. When an operator performs a close Apple reset oi In these discussions, the use of a multimeter, logic a functional Apple He, the reset routine at $FA62o. probe, or oscilloscope will be occasionally called for. the motherboard EO— FF ROM is executed. Severa If you do not have access to the instrument men- subroutines are immediately executed via JSR in tioned ,or you do not know how to use it, it is time to structions, and then flow is passed to $C100 via th( get your system to a dealer. Incidentally, you can GOTOCX subroutine. If at $C23F, close Apple is buy a logic probe and a multimeter for $20 each at found to be held down, flow will then be passed to th« Radio Shack and learn how to use them in a few diagnostic routines at $C401. The contents of tht minutes. diagnostic routines are as follows: If you manage to find the exact causeof a problem, you can buy most Apple components in computer 1. Initialization at $C401 includes saving open electronics stores or, more expensively, at computer Apple key status, stack pointer = $FF, CSW = dealers. The lOU and MMU, of course, can only be COUTl, disabling high RAM for reading and purchased at an Apple dealership or directly from writing, and calling the HOME subroutine. Apple Computer, Inc. The computer dealer will 2, An MMU soft switch check at $C41D consists charge you more than an electronics store for parts, of reading (at $C011— $C018)and verifying the because he is not in business to sell electronic com- *The firmware diagnostics are described here as they are in the ponents. Like virtually all American maintenence original Apple He firmware. Please note that, in the enhanced operations, the computer dealer will put a big mark- firmware, the diagnostics reside at $C600— $C7FF, there is no ROM check, and both motherboard and auxiliary card RAM are up on his parts prices to improve the prof itablity of checlted. See Chapter 6, The Apple lie Firmware Upgrade for his service department. a description of the enhanced firmware. Table 10.1 MMU Soft Switch Diagnostic Error Codes. SOFT SWITCH INITIAL STATUS CHANGED STATUS BANKl 0 8 HRAMRD 1 9 RAMRD 2 A RAMWRT 3 B INTCXROM 4 ALTZP SL0TC3R0M 5 c 6 D 80STORE 7 E Maintenance and Care of the Apple He 1 0-7 diagnostic routine input status of the MMU soft toggled descending ($C64C), and again descend- switches. Then the state of the MMU soft ing ($C6AD). During these checks, the speaker switches excluding INTCXROM is changed is toggled at about 10,000 Hz if open Apple was and the $C011-$C014 and $C016-$C018 sta- held down when the diagnostics were initial- tus is verified. If any errors are detected, the ized. Ifan incorrect value is read at anytime message "MMU FLAG E4:a b . . . n" is printed during these checks, the message "RAM: Fa Fb. where (a b , . . n) are error codes indicating . . Fn where (Fa Fb . . . Fn) are those RAM chips errors as shown in Table 10.1. of RAM chips F13— F6 yielding incorrect data 3. An lOU soft switch cheek at $C498 consists of (example: RAM:F13 F8 F6). The system then reading (at $C01A— $C01F} and verifying the hangs at $C714 with the RAM error message diagnostic routine input status of the lOU soft displayed. Memory location $01 contains the switches. Then the state of the lOU soft switches memory page in which the error was detected. is changed and the $C01A— $C01F status is 9. If no errors are detected and open Apple and verified. If any errors are detected, the message close Apple are not both held down at the com- "lOU FLAG E5:ab . . . n" is printed where (a b . . pletion ofdiagnostics, the message "KERNEL . n) are error codes indicatingerrors as shown in T^ble 10.2. OK" is displayed, then the program hangs at $C72D. "KERNEL OK" means the diagnostics 4. After the lOU soft switch check, the program passed, that ROM. RAM, and the soft switches hangs at $0510 with error messages displayed are good, and that the programmer who wrote if there was an MMU or lOU error. If there was the diagnostics was more interested in u.seleas no MMU or lOU error, the Cl— DF ROM check jargon than in a meaningful English language is performed. message. 5. The Cl— DF ROM check at $C53F consists of 10. If open Apple and close Apple are both held summing $C100-$DFFF excluding $C400— down when the RAM diagnostics are completed $C4FF and comparing the result to the contents without error ($C720), an I/O exercising pro- of $C400. If the sum is wrong, the message gram ismoved from $C7AE— $C7E2 of ROM "R0M:E8" is printed and the program hangs at to $0100— $0134 of RAM and executed. This $C569. Otherwise, the EO— FF ROM check is program enables slot I/O {$C7AE), makes performed. ascending read and write references to $C090— 6. The EO— FF ROM check at $C56C consists of $CFFF($C7B6), makes descending read refer- summing $E000— $FFFF excluding $F7FF ences to $C079-$C000 ($C7CF). then disables and comparing the result to the contents of slot I/O and recycles the diagnostics ($C7DA). $F7FF. If the sum is wrong, the message "ROM:E10" is printed and the program hangs Some aspects of interpreting diagnostic perfor- at$C58E. Otherwise, the RAM check is begun. mance are obvious, but others are not. Here are a 7. The motherboard RAM check at $C591 be- few notes about diagnostic interpretation: gins, after a short initialization, by filling all motherboard RAM, but not auxiliary card 1. If one of the ROM chips is bad. the portion of RAM, with $00 ($C5A8). Duringthis initial zero reset routine beginning at either $FA62 or fill, the speaker will toggle at about 180 Hz if $C100 will not be fetched and executed. If a open Apple was held down when the diagnostics RAM chip is bad. then the flow will not return to were initialized. the reset handler after subroutines are executed 8. RAM is checked and toggled ascending($C5EB), because the return link information will not be and again ascending ($C64A), and cheeked and correctly saved and retrieved from the slack. In Table 1 0.2 lOU Soft Switch Diagnostic Error Codes. SOFT SWITCH INITIAL STATUS CHANGED STATUS TEXT 0 8 MIXED 1 A PAGE2 2 9 HIRES 3 B ALTCHRSET 4 7 80COL 5 6 '..■ll^ym 10-8 Understanding the Apple He execution is selected, the first task is to verify other words, if a RAM or ROM chip is com- Rav pletely bad, flow will never arrive at $C401 and Page 1 and Page 2, again in a routine that do^ utilize RAM except to verify it. This routi Z the diagnostics will not be executed. ne shouM 2. There are four major checks performed in the be executed many times to absolutely verift reliability of these critical pages. Failu r the following order: soft switches, CI— DF ROM, re of th^ EO-FF ROM, RAM. If any of these checks Page I/Page 2 verification should be indicated bv fails, an error condition is indicated and the speaker beeps, and passage would enable diagn contmuation with knowledge that indirect ostic remaining checks are not performed. address 3. Memory locations in Page Oof RAM are utilized mg and the stack can be used. in performance of all checks, and error printing Once Page 1 and Page 2 of RAM are verified the subroutines are called via JSR instructions. programmer has freedom to make all sorts of checks Therefore, ifthe diagnostics were somehow per- including complete RAM, ROM, MMU, and lOU formed with Page 0 or Page 1 malfunctioning, checks. Complete diagnostics would certainly verify performance would be unreliable. auxiliary card RAM. the MMU memory configura- 4. The RAM test audio tones provide a means of tion capabilities, and the existence of 17030 cycles in verify ing diagnostic performance in the absence VBL. All pass/fail indications should be via speaker of video display. This is true, even when the beeps (Morse code?) in addition to video display so speaker is disconnected, because the LED con- the diagnostics could be interpreted when the dis- nected across the speaker jack will glow during play was malfunctioning. A diagnostic EO— PF the 10000 Hz toggling if the speaker is discon- chip like this would isolate some problems that nected. might occur in an Apple He. At least they would 5. An intermittent error might show up only if the give you a decent indication before you warmed up diagnostics are recycled many times. To recycle the oscilloscope. the diagnostics, turn off the Apple lie and dis- connect the keyboard plug, paddles or joysticks The Peripheral Card Check with pulled down pushbuttons, and any periph- eral cards that would interfere with recycling. A cheek that should be made at an early point for Remove the disks from all of your disk drives* almost any persistent symptom is to turn off the and turn on the Apple lie. The diagnostics, Apple, remove the auxiliary card and all peripheral including the portion that exercises I/O, will cards, turn the Apple on, and see if the symptom recycle until an error occurs or you turn off the disappears. If it does, you can find which card is Apple He. causing the fault by turning the computer on with each card installed by itself. Then you can operate Since operation of the diagnostics is normally the Apple, losing only the capabilities represented precl uded by bad RAM or ROM, the diagnostics are by the malfunctioning card until it is repaired. Even good for verifying good memory, not troubleshoot- when a peripheral card or auxiliary card is known ing bad memory. Properly conceived Apple He diagnostics would reside solely in the EC— FF ROM. to be malfunctioning, it is a good idea to check oper- ation with all other cards removed. For example, In this ROM, the first action taken at any reset your disk controller may be loading down the would be a BELL routine which did not depend on RAM to operate correctly. The ability to execute a RESET' line and causing the printer card to misbe- stored sequential program would thus be verified have. This procedure of isolating a problem to a peripheral card will be referred to as the periph- independently of RAM. If the BELL does not ring, eral card check. Other than this most basic of RAM and the CI— DF ROM have nothing to do with checks, your course of action will depend on your it. After ringi ng the BELL, the next step would be to symptoms. The most easily recognized symptom is a check the close Apple button to see if diagnostic completely dead Apple, normally indicating a power supply problem. execution is selected by the operator. If diagnostic Power Supply Problems •Increasing references through the disk controller DEVICE SELECT' addresses leave all stepper phases on and drive 2 on There are two symptoms you will normally en- and configured for writing. This does not wipe out the disk in counter with power supply problems. The Apple is drive 2 if phase 1 on forces write protection in your drive like it dead and there is a low level clicking noise coming does in the Disk II drive. Prudence dictates that you remove all from the power supply, or the Apple is dead and disks before recycling the diagnostics. silent too. If there is a clicking noise, the power Maintenance and Care of the Apple We 10-9 verify a short to ground exists with a multimeter and try to isolate the short by removing ICs from the motherboard, peripheral card, or auxiliary card in groups until the short goes away, You can do this yourself, but beware. Even experienced technicians damage ICs or install them incorrectly on occasion. If you remove all the ICs from a card and put them back in, you very well may create some casualties that weren't there when you started. Also, the prob- lem may be more difficult than a dead short, and you might end up requiring a board replacement if it is too difficult. The second bad power supply symptom that can be observed is a completely dead Apple with no clicking noise. This can be verified to be a power supply problem by measuring the +12, -12, +5, and Figure 105 A Power Supply WIfh ttie BoWom Off. -5 volt lines at any peripheral slot with a multime- ter. Ifthe voltages are good, then a timing generator supply is quite likely g-ood, but a motherboard, pe- problem is indicated. If incorrect voltages are pre- ripheral card, or auxiliary card malfunction is caus- sent, there is probably a power supply problem ing an overload condition. IftheAppieisdead silent, which will require a swap out from a dealer. If no there may be a casualty in the power supply itself. voltages are present, a dealer may still swar) out the The clicking noise is the tinkerer's symptom. power supply, but you may only have a bad switch. Chances are very good that somebody was instal- In the event the power supply switch fails, you ling, removing, or modifying something in the have two options. You may take the computer to a Apple. When any casualty symptom follows tinker- dealer who might verify the switch is bad and ing, concentrate your investigations in the areas replace it or who might insist on a power supply that were tinkered with. If something was touched, swap out. You may also verify the switch is bad look it over. yourself and replace it. Any Apple dealer will carry When the clicking noise occurs, turn the computer the switch or can obtain it from Apple. Here is a off immediately. If a component has just shorted, it rough procedure for replacing the switch. may be hot or show evidence of burning. Visually 1. Turn the Apple off. inspect the motherboard and peripheral cards under 2. Remove the power cord from the power supply. good lighting. Look for such things as ash or black H. Disconnect the power supply plug from the marks on the components. Touch al! the ICs lightly motherboard connector. to see if any are hot. Be careful or you might burn your finger when you get to the right one. Check that •1 Remove the power supply (four screws through all cards, plugs, and ICs that may have been tin- Apple base plate). 5. Remove five screws from both .sides of the power kered with are correctly installed , not reversed , and with no shorted pins. Perform the peripheral card supply and separate top from bottom. 6. Verify switch casualty with ohmmeter. check, but don't leave the computer on with the clicking noise for any longer than necessary. The 7. Replace switch. 8. Reassemble and reinstall the power supply by peripheral card check will indicate whether the reversing the dismantling procedure. motherboard or a peripheral card is the probable cause. It can be further determined that the prob- DO NOT APPLY POWER TO THE POWER lem isnot in the keyboard or numeric keypad by SUPPLY WHILE INTERNAL COMPONENTS disconnecting the keyboard plug and numeric key- ARE EXPOSED. THE VOLTAGES INSIDE Pad plug (if there is one) from their motherboard sockets. ARE VERY HAZARDOUS WHILE POWER IS APPLIED. K you were unable to isolate the exact problem cause, It may be time for you to take your system to a Peripheral Failures aealer for repair. At this point, you will be able It is sometimes fairly obvious that the problem to describe the symptoms to the service technician on lies only in a peripheral or its interface card. If a level which will be helpful to him. He will probably everything else works, but a printer won't print, it's 10-10 Understanding the Apple He that the drive was always configured for writine pretty cut and dried. Other peripheral failures are even when the controlling program was attemptini less obvious. Cards that steal memory addressing such as a firmware or RAM card are so integrated to read data. Booting or cataloging a disk, for exam pie, would clobber the disk. A typical operator wil into the overall operation that when one fails, symp- clobber several disks under these circumstance toms can be the same as motherboard failures. before realizing what he is doing. He thinks he i When you are certain that a fault lies with a pe- trying to read bad disks, but he is really makinj ripheral, there are some steps you can take to try to determine the exact cause. First, with the computer disks go bad while trying to read them. If yoi off. remove all the other peripheral cards and the encounter these symptoms, try replacing the LSl2i on the analog card of the offending drive or drives auxiliary card to be certain that one of them isn't Then verify operation with disks containing non somehow causing the problem. If that doesn't help, critical data. This tip also pertains to most seconc turn the computer off, and give the suspect periph- eral card a visual inspection. Assuming the ICs are source B-Vt inch drives available for the Apple. Thej mounted in sockets, wiggle them all to make sure generally use an LS125 for the same functions as th< one in the Disk 11 drive. that they're properly seated. Verify that any plugs are properly installed. Clean the contacts of the Other Symptoms card's edge connector with a pencil eraser or with alcohol and cotton swabs, preferably the latter. There are no error lights built into the Apple, bui Reinstall the card and verify that the problem still there are some very distinct error indications which exists. You can perform the same steps on any cards you can interpret if you understand the Apple. mounted in the peripheral itself. First, does it beep when you turn it on? The beep Just the act of removing a peripheral card and isn't made by some oscillator. It's made by pro- installing it will often cure many problems, at least grammed control of the speaker by the MPU. It temporarily. Some lower quality contact materials means that a power-up RESET was generated, the will tend to make poor electrical contact when the 6502 works and is capable of address bus and data temperature rises. Just wiggling the card can cure bus control and data bus reception, the EC— FF and the problem, but be sure to wiggle it with the com- CI— DF ROMs work, timing works, page 0 and 1 of puter turned off. Cards with gold plated contacts RAM work, the MMU works, a good portion of the are much less likely to cause this sort of trouble. address decoding circuitry works, and the lOU is Another thing you can try is to run the peripheral capable of toggling the SPKR line in response to in a different slot than its ordinary one, assuming it address bus commands. In other words, if the is not slot dependent. If it is slot dependent, try speaker beeps, the Apple is in pretty fair shape. running another peripheral in that slot, the object The second big indicator of the nature of a prob- being to prove there is nothing wrong with the slot's lem is the video display. The scanning of RAM for signals or connections. If the problem persists, you video output is done independently of the MPU and may as well start calling computer dealers to find the address bus. The only common bonds are timing one who will work on your peripheral. and the data bus. The address bus, MPU, MMU, If you cause a malfunction by removing a card RAM, and Cl-DF and EO-FF ROMs can all be with power applied, suspect that ICs connected to burned to a crisp, and you will still have the display the INHIBIT' line are burned out. This includes the window on the screen. The contents would be jibber- 74LS09on a firmware card or a RAM card. You can ish, but the window would be there with its black burn up these LS09s by removing any card from any margins on all sides. The presence of the window slot with the power on and accidently shorting pin means that timing, the video scanner, and most of 32 (INHIBIT') to pin 33 (-12V). If you are less the video generator are working. lucky, you might short pin 50 (+12V) to pin 49 (DO). The four possible combinations of the two opera- In the latter instance, you may possibly destroy numerous ICs. tional indicators can greatly narrow the field of pos- sible causes of a given problem. The following Here is one last tip for a special situation. I have interpretations of symptoms should help. In all known the LS125 on the Disk II analog card to be cases perform the peripheral card check, visually damaged on three separate occasions. On two of inspect the motherboard, and verify all ICs are those occasions, the LS125 failure was caused by a properly seated. Refer to Figure 10.3 (color section) person plugging the 20-pin ribbon cable connector to see which functional areas are affected by various into the controller incorrectly. The symptom was ICs. Maintenance and Care of the Apple lie 10-1 1 1. No beep, no display. This is one dead Apple and the procedure given in The Firmware Diag- power supply problems are the probable cause. nostics section. Check all the signals on a peri- This can be verified by measuring the +5V, pheral slot with a logic probe or oscilloscope. -5V, +12V, and -12V supplies at any periph^ eral slot with a multimeter. If any of the volt- Intermittent problems are the bane of all comput- ages isincorrect, read the Power Supply Prob- er servicemen as well as computer users. They are lems section of this chapter for an indication as often dependent on the temperature and the product of a mechanical defect like imperfect electrical con- to how to proceed. If the power supply voltages tact. They are sometimes impossible to repair in a are good, timing generator problems are indi- cost effective way and the best thing that can be cated. Verify the presence of the timing genera- done in this instance is to swap out the defective tor signals using a logic probe or oscilloscope. If assembly at a computer dealership. There are two you have a second Apple lie or simply have tricks which can be used to make the problems access to spare ICs, swap out the motherboard become more regular so the causes can be identified. timing HAL, LS125, LS109, and lOU one by one One is to subject the equ ipment to asevere mechani- to see if one of these ICs is causing the problem. cal jolt, like Humphrey Bogart in The Africirn 2. No beep, display window present. Timing is Qiu'oi. This will tend loproveor disprove the notion good, but the computer does not execute a stored that there is a mechanical problem, Lessdrastically, sequential program. Many things cou!d cause you can flex the motherboard and reseat su.spect this symptom including the MPU, the lOU, the peripherakardsandlCs. The second trick is to raise MMU, a ROM chip, a RAM chip, or any bad and lower temperature to make the problem occur, chip connected to the address or data bus. You "('old problems" can be made toappear by spraying may try to get an indication from the firmware cold spray, available at electronic stores, on sus- diagnostics, but they probably will not run. Use pected areas. " Hot problems" can be made to apjjear a logic probe or oscilloscope to verify whether or by directing a heat gun. or, less effectively, a hair not signals are normal at all pins, at one of the dryer at the suspected area. peripheral slots, and at the auxiliary slot. Pay There are no doubt many .symptoms not covered particular attention to the address bus, the data by the guidelines that have been given here. The bus, INHIBIT', RESET', and other 6.502 con- intention was only to give .some helpful hints, not a trol lines. The condition of the peripheral slot full blown maintenance aid. A serious reader of this signals should guide you to possible causes. book, however, should be in a very good position to 3. Beep, no display window. Most of timing is correctly interpret the .sym|)toms of any malfunc- tions which occur in his machine. In the absence of good, butcheckLDPS' and VID7M with a logic probe or oscilloscope. Also check the lOU out- sophisticated diagnostic aids, full understanding of puts related to video generation and the PIC- operation is the most important asset in isolating faults in a digital computer. It is good for Apjjle TURE' signal (see Figure 8.5). Verify that the firmware diagnostics operate correctly by hold- owners to possess this level of understanding, and it ing open and close Apple while pressing CON- is also good for them to locate comj]utcr dealerships TROL-RESET and listening to the speaker. which employ service per.sonncl with this level of understanding. Suspect the lOU if you don't hear the RAM test speaker tones. If you have access to spare ICs, you can replace the ICs and transistors pictured m Figure 8.5 one by one to see if one of them is causing the problem. ,1_ 4. Beep, window present, programs crash. The computer executes programs but gets into trouble in certain cases. If they will operate, run the firmware diagnostics with all peripheral cards installed and again with peripheral cards ii;^)b-.^' removed. Follow up any leads the firmware diagnostics give you. If the diagnostics will not run, suspect RAM or ROM. If the diagnostics run and pass, recycle them for a longtime using Figure 104 Some People Just Shouldn't Handle ICs. glossary address bus. A multi-line electrical connection from the auxiliary slot. The 60-pin receptacle located on the left MPU to various devices in a microcomputer by side of the Apple lie motherboard. The auxiliary slot which the MPU specifies the location with which it is designed to accept cards that support the Apple He will communicate. The address bus in the Apple He 80-eolumn video and 64K auxiliary RAM capabilities is made up of 16 lines, and the MPU can specify and functions related to video and timing generation. 65536 different addresses for data transfer. See data bandwidth. A frequency range. Usually, the frequency bus, R/W' line. range of sinewaves that will be processed or passed ampere, amp. The unit of measure of electrical current. by an electronic circuit or signal path. analog. Pertaining to quantities which vary through a continuous range such as a voltage which ranges bank switching. A method of accessing more memory locations than the normal addressing range an MPU from +5V to -6V. See digital. will allow. In bank switching, the MPU is allowed by AND gate. A logic gate from which the output will be hardware to address more than one memory bank true if and only if all of its inputs are true. using the same address range. An example is the Applesoft BASIC. The floating point BASIC interpre- $D000— $FFFF range of the Apple He which is bank ter language written for the Apple II by Microsoft, switched between motherboard ROM, motherboard Inc. and distributed by Apple Computer, Inc. RAM, and auxiliary card RAM. ASCII, American Standard Code for Information Interchani^. A code for representing numbers, let- BASIC, Beginners All-purpose Symbolic Instruction ters, and symbols in computers. ASCII is used in the Code. The primary high level language used in per- Apple He for representing text in the keyboard input, sonal computers. It was originally developed at Dart- text screen map, printer output, BASIC strings, and mouth College as a training language, and has been DOS text files. developed into a powerful and usable tool by the assembler. A program which converts an assembly microcomputer industry. language source file into a machine language object file. binary numbering system. A system based on powers as opposed to powers of 10 in the decimal sys- of 2, tem. assembly language. A language which specifies ma- The two symbols of the binary system are 0 and chine language commands on a one to one basis but 1. See hexadecimal. in which the computer manages many of the details bit. A 2-state unit of information. The information is in of generating machine language code. one state or the other—on or off, for example. ^i-yf-^^ 2 Understanding the Apple He with each other-HIRES40 green and HIRES40 vio- bomb, crash. When a program is bombed or when it let for example, simply crashes, it loses control of the computer and composite video. A complex video display signal con must be restarted and possibly reloaded. It is partic- taining horizontal and vertical sync, luminance and ularly likely for a program to crash when it is first chrominance signals, and a color burst The video written and still has bugs in It. output of the Apple He can loosely be called comDo- bonding options. Optional characteristics of a custom site video. IC that are determined when the IC is manufactured CSW, Character output SWitch, See I/O links. by bonding signal lines to low or high signal points. For example, selection of Apple lie or Apple lie current. The motion of charged particles due to voltage operational characteristics is a bonding option of the Generally, in electronics, the movement of electrons MMU and lOU. through conductive paths. Current is measured in bootstrap. The process by which a computer loads large amperes. operating systems using a small firmware program, custom IC. An IC which is manufactured to suit the buffer. (1) A temporary holding area in memory in special needs of an equipment manufacturer. The which data resides before, during or after transfer lOU and MMU are examples of custom ICs. operations. (2) Any hardware device which provides cycle stealing- DMA. Direct memory access from a electrical isolation between two electrical points or device other than the MPU which occurs while MPU sets of points. execution cycles are inhibited. Cycle stealing DMA bus. A multi-line electrical connection which distributes slows execution of the MPU program. an associated group of signals among two or more data bus. A multi-line electrical connection over which communicating devices. data passes between the MPU and various devices in bus driver. A group of amplifiers which allow a group a microcomputer. The data bus in the Apple He is of signals to control a heavily loaded bus. The driver made up of 8 lines, so one byte can be transferred per gives electronic leverage to the control signals so they MPU cycle. See address bus, R/W' line. can "drive" many devices. debounee. To eliminate signal variations resulting from byte. A group of 8 bits. The 6502 is an 8-bit MPU and the short period of unstable contact that occurs after therefore transfers and manipulates data one byte at a mechanical switch is thrown. a time. debug. Do perfect a program by removing the bugs BYTE FLAG. A term used in this book to describe the (defects) from it. sync bit which leads groups of eight bits in Apple decimal numbering system. The system by which we DOS data formats. normally represent numeric quantities. Ten symbols card cage. A row of receptacles into which printed cir- (0 — 9) represent quantities, while the position of each cuit cards with edge connectors are plugged. The symbol in a number represents the significance or receptacles are wired in the back as is necessary to weight of that symbol. The weight increases by pow- implement the functions of the cage. ers of ten as position shifts right to left. cathode ray tube, CRT. A device in which a screen digital. Pertaining to quantities which vary in discrete display is created by a high velocity stream of elec- increments such as integer numbers. See analog. trons striking a phosphor coating. The impact point on the screen is controlled by deflecting the electron DIIDD, Disk II Device Driver. The subroutine of stream via an electromagnetic or electrostatic field. ProDOS that is called to read or write a 512-byte The picture tube in a television is a CRT. block of floppy disk data. See RWTS. central processing unit, CPU. The electronic assembly DIP, Dual In line Package. A type of electronic com- which performs the arithmetic and logical operations ponent structure in which pins run lengthwise in two of a computer. parallel rows. All ICs in the Apple lie are DIP ICs, chip. See integrated circuit. there but tor are some SIP (single in line package) resis- networks. COLOR BURST. In a television color video signal, a short sample of the COLOR REFERENCE signal disassembler. A program which attempts to interpret which occurs just after the horizontal sync pulse. data in memory as a machine language program and From the COLOR BURST, a television or monitor converts it to an assembly language listing. A firm- can reconstruct the COLOR REFERENCE. ware disassembler in the Apple lie can be called viJ the monitor "L" command, compiler. A program which converts high level lan- guage source programs into machine language object DMA, Direct Memory Access. Direct access to mem programs. ory from devices other than the MPU. In the Appk complement. The complement of a binary number is a He, data is directly accessed in memory by the vij« scanner/video generator combination without MPL binary number in which binary "l"s replace "0"s, and participation. Additionally, a card in any periphera "0"s replace "l"s in the original number. For exam- slot can directly access memory and other mother ple. 11010 is the complement of 00101. complementary colors. Pertaining to the Apple He, board devices by pulling the DMA' line low. colors produced by signals 180 degrees out of phase dot matrix. A method of forming displayed or printet characters in which individual dots at fixed positioni •Glossary 3 in a matrix are displayed as necessary to form the The lines of force provide a mental picture for visual- characters. izing the substance of a magnetic field. In theoretical DOUBLE-RES mode. A term used in this book to refer calculations, density. field strength is proportional to flux to the double horizontal resolution (motherboard and auxiliary card map) display mode of the Apple He. font, character. Patterns of ONEs and ZEROs stored DOUBLE-RES mode is further categori in memory which represent the dot image of dot TEXT80, LORES80. and HIRES80 modes.zedSeeasSIN- the matrix text or graphics characters. GLE-RES mode. frequency response. The response of an electronic cir- driver. (1) A program which manages specific hard- cuit or device as frequency varies. Good high fre- ware or I/O functions, e.g. a printer driver. (2) A quency response is required in video monitors used hardware device that supplies signals at the voltage with high resolution video computers like the Apple and current required by other hardware devices, e.g. lie. the Apple He bidirectional peripheral data bus driv- er. gate. A logic circuit having one output and more than one input. Like a gate in a fence, the logic gate allows Dvorak keyboard layout. An alphabetic keyboard lay- intelligence to pass when the inputs are correct. AND out that is designed to allow faster touch typing gates and OR gates are two types of gates. When an speed than the standard QWERTY layout. Dvorak is available as an alternate layout in the keyboard ROM input activates a logic device, it is said to "gate" it on. of the American Apple He. general purpose computer. A computer whose stored program may be altered to change its purpose. This dynamic memory. Memory in which data will bleed off is normally achieved by storing the program in ran- and lose its validity if it is not regularly refreshed. dom access, read/write memory. See special purpose RAM in the Apple He is dynamic and must be re- computer. freshed every 2 milliseconds. hacker, hack, computer hack, A person who builds or Easter egging. A troubleshooting method where possi- modifies computer electronic assemblies, mostly for bly failed components or assemblies are replaced fun. More loosely defined, any person who thinks with known good units. Easter eggers can sometimes computers are fun. repair equipment they know little or nothing about. edge sensitive input. An electronic circuit input which HAL, Hard Array Logic. An IC whose logical func- tions, within a given framework, are fixed when it is is sensitive only to changes in signal level. The 6502 manufactured. HAL is similar to masked ROM ex- NMI' input is an edge sensitive input which responds cept that logical functions, instead of stored data, are only to negative voltage transitions. See level sensi- specified. See PAL. tive input. EPROM, Erasable Programmable Ftead Only Mem- handler. A program designed to handle a specific oc- currence such as an interrupt or system reset. ory. A type of PROM that can be erased and repro- grammed. Subtypes include UVEPROM (ultraviolet hardware. The components and assemblies of which a light erasable PROM) and EEPROM (electrically computer and its peripherals are marie. erasable PROM). See ROM, PROM. Hertz, Hz. A unit of frequency measurement which exclusive OR gate. A logic gate from which the output used to be referred to more sensibly as cycles per will be true if and only if at least one. but not all, second or cps. inputs are true. hexadecimal numbering .system. A .system based on firmware. Programs and data stored in ROM. Firm- powers of 16, as opposed to the powers of 10 in the ware determines many of the operational features of decimal system. The 16 symbols of the hexadecimal the Apple He. system arc 0, 1, 2, 3, 4, 5, 6, 7, S. 9, A, B. C. D. E and F. flag. (1) A memory location used by a program to sig- nify some sort of status. A common way to use a loca- high level language. A computer language whose com- tion as a flag is to set or reset its most significant bit. mands correspond to machine language routines. (2) A readable indicator of hardware status such as High level languages are easy to use and powerful. _the status flags of the 6602, MMU, and lOU. The predominate high level language of the Apple flip-flop. A 1-bit storage device capable of storing data He is Applesoft BASIC. in response to its logical inputs and a clockpulse. high RAM. A term used in this book to refer to RAM in Registers of older computers were comprised of a the Apple He that is addressed at gDOOO— $FFFF. number of flip-flops with a substantial amount of horizontal scan. The movement of the electron beam in associated logic gating. a television from left to right across the face of the float. If all devices capable of controlling the voltage on CRT. an electrical conductor are isolated from the conduc- impedance. The quality of hindrance of an electrical tor, the conductor is said to float. In the Apple He, all device to current flow at a given signal frequency or conductors on the address bus or data bus can be iso- lated from control, so these buses sometimes float. range of signal frequencies. Impedance, like resis- tance, ismeasured in ohms. In computer 3-state logic, Logic which creates this condition floats the bus. the three states are high voltage, low voltage, and flux. Lines of force used to represent a magnetic field. high impedance (high isolation). 4 Understanding the Apple lie are 556 (on the disk controller) and 558 timers anri I/O links, I/O hooks. Memory locations which contain the 741 cassette input amplifier. the addresses of the primary input and output rou- LSTTL, Low powered Sehottky TTL. A type of TTl tines ofthe Apple He. The output link is CSW (Char- which provides a good compromise of high speed and acter output switch, locations $36 and $37), and the input link is KSW (Keyboard input SWitch, locations low power consumption. Most Apple He TTL is $38 and $39), LSTTL. The name comes from Schottky-Barrier clamping and coupling diodes inside the IC. I/O port. The conceptual entry point through which data flows in I/O operations. For example, in the machine cycle. A clocked cycle of an MPU. The ma- Apple He, $C0OO is the address of the keyboard input chine cycle of the 6502 in the Apple He is the period port, and keyboard data is loaded from address between high to low transitions of the PHASE 2 $C000. clock. machine language. The language of the central pro- input/output, I/O. The process of moving- information cessor, ofa computer (6502 machine language in the to and from a computer, as in keyboard input, video outjiut, disk I/O. and printer output. Apple He). Integer BASIC. The original BASIC interpretive lan- mainframe computer. When computers were physi- guag-e, supplied with the Apple II and Apple lie. It cally large, the structure which held the central pro- was written by Steve Wozniak, the principle designer cessor was called the mainframe. Computers which of the original Apple II computer. Integer BASIC is have such separate structures are mainframe com- included on the DOS ,3.3 system master and can be loaded to and run resident in Apple lie high RAM. Megahertz, puters, MHz. One million Hertz. One million integrated circuit, IC, chip. An electronic component cycles per second. into which the functions of many other components memory cell. A portion of memory capable of storing are integrated. Ti'pically. a chip will be the equiva- one bit of information. lent of thousands of diodes, transistors, and resistors. memory mapped I/O. A method of I/O implementation interface. Communication circuitry between two de- in which addresses are assigned to I/O functions. The vices, such as the interface between an Apple lie and Apple lie uses memory mapped I/O, and Apple He a printer. I/O device addresses are in the $C0O0— $CFFF range. interlacing. A technique in which alternating televi.sion memory mapped video. A method of computer video vertical scans are displaced from each other. This in- display generation in which a map of the screen dis- creases vertical resolution without introduction of screen flicker. play isplaced in memory. In the Apple He, the MPU builds the screen map in memory, and the memory interpreter. A program which interprets stored se- map is independently scanned for video processing quences ofhigh level commands and executes them by video scanning circuitry in the lOU. via fixed machine language subroutines. The Apple He is supplied with Applesoft BASIC interpreter in microprocessing unit. MPU, microprocessor. The 1- ROM. ehip central processing unit of a microcomputer. This definition is a good subject for an argument, interrupt. A signal or instruction which, when active, causes a computer to interrupt sequential program microsecond, ^usee. One millionth of a second. One thou- sand nanoseconds. execution and branch to an interrupt handling pro- millisecond, msec. One thousandth of a second. One gram. The 6502 has four types of interrupts: RESET. thousand microseconds. the Non-Maskable Interrupt, the Interrupt Request, and the BREAK instruction. MMU, Memory Management Unit. A custom IC that lOU. Input/Output Unit. A custom IC in the Apple He manages overall response to MPU addressing in the and Apple lie which performs logical functions re- Apple He and Apple lie. lated to video output and other I/O. mnemonic. That which is intended to assist our memo- joystick. A device which converts the two dimensional ries. MPU op codes reside in memory as binary num- motion of a lever into measurable electrical equiva- bers, but they are referred to by mnemonic labels lents ofthe X and Y components of the motion. Nor- such as LDA (LoaD Accumulator) in assembly lan- mally an Apple lie joystick wilt be made of two guage programs. potentiometers, one which responds to y-axis motion modulate. To vary a high frequency signal as a function of the lever and one which responds to x-axis motion. of a lower frequency signal. The video output signal KSW, Keyboard input SWitch. See I/O links. of the Apple He can be used to amplitude modulate a least significant bit, LSB. The bit of a binary word or television frequency signal, and that modulated sig- number which has the least weight or significance. nal can be received by a television set. The high fre- The rightmost bit of a binary number. called anquency RF signal carries the video to the TV and is carrier. level sensitive input. An electronic circuit input that monitor. A program which provides for communication responds to stable voltage levels, not just changes in voltage levels. The 6502 IRQ' input is an example of a with a computer at a very basic level. Common capa- level sensitive input. See edge sensitive input. bilities include program start up, memory modifica- tion, and monitoring of computer registers. linear IC. A type of IC used in linear amplification and other analog functions, as opposed to digital switch- monitor, video. An electronic device which generates a mg functions. Some linear ICs used in the Apple He display from a video input signal. It is not capable of television radio frequency signal reception. Glossary 5 monochrome. Of one color. A name for black and the carry bit of the 6502 Status Register. television which accurately describes the factwhite there is only one color tone displayed. that OR gate. A logic gate from which the output will be true if, and only if, any of its inputs are true. MOS integrated circuit. A chip using metal-oxide oscillator. An electronic circuit that generates an out- semiconductor technology. MOS ICs in the Apple include the 6502, ROM, RAM, the lOU and the He put signal that alternates between high and low vol- MMU. tage peaks. The 14M signal is produced by a 14.31818 MHz oscillator in the 60 Hz Apple He. most significant bit, MSB. The bit of a binary word or oscilloscope, A test instrument which produces a cath- number which has the greatest weight. The leftmost bit of a binary number. time.ode ray tube display of a test voltage, plotted against motherboard. A printed circuit card into which small- page. (1) The 6502 memory addressing range of $10000 er printed circuit cards can be plugged. bytes is divided up into $100 pages of 1100 bytes multimeter. An instrument which can measure electri- each. 1000— $OFF is Page 0; $100-$1FF is Page 1; cal voltage, resistance, or current. etc. (2) There are four RAM address ranges that can multiplex. Tb combine multiple sources of information be scanned for video output in the Apple He. These onto one tine. There are a number examples of time- are TEXT/ LORES PAGE 1, TEXT/LORES PAGE multiplexing in the Apple He in which several possi- 2. HIRES PAGE 1, and HIRES PAGE 2. PAGE ble signals are switched onto a line, one after the 1/PAGE 2 selection in the Apple He is performed via other. programmed manipulation of the PAGE2. 80STORE and HIRES soft switches. NAND gate. A logic gate from which the output will be false if, and only if, all of its inputs are true. PAL, Phase Alternating Line. The television system nanosecond, nsec. One billionth of a second. used in most western European countries and some other countries. See NSTC, SECAM. negative logic. A system of logic analysis in which the high voltage state is considered to be false or zero, PAL, Programmable Array Logic. An EC whose logi- and the low voltage state is considered to be true or cal functions, within a given framework, can be pro- one. See positive logic. grammed after the IC is manufactured. PAL is NOR gate. A logic gate from which the output will be similar to PROM except that logical functions, in- stead ofstored data, are programmed. See HAL. false if, and only if, any of its inputs are true. NTSC, National Television Systems Committee. The PAL motherboard. The version of the Apple He moth- television system used in the United States and some erboard which is operated in countries that do not other countries. See PAL, SECAM. use the NTSC television system. PAL motherboards have a PAL color video encoder built in. See NTSC NTSC motherboard. The version of the Apple He moth- motherboard. erboard that is operated in the United States and other countries that use the NTSC standard televi- parallel data transfer. Simultaneous transfer of n bits sion system. See PAL motherboard. of data on n lines, as in 8-bit parallel data transfer between the MPU and memory in the Apple He. object file. The result of an operation which processes a group of data and stores the result elsewhere. In peripheral slots, peripheral bus, Apple bus. The assembly language processing, the assembly language seven slots in the back of the Apple He and their associated electrical connections. source file is assembled into a machine language object file. phase. The angular position of a cyclic event referenced octal numbering system. A system based on powers of to some event of the same frequency. For e.'tample. HIRES violet video is 180 degrees out of phase with 8, as opposed to the powers of 10 in the decimal sys- HIRES green video. tem. The eight symbols of the octal system are 0. 1, 2 3, 4, 5, 6, and 7. pipelining. A process by which program execution ohm. The unit for measuring electrical resistance and speed is increased in the 6502. In pipelining, the next impedance. instruction's op code i.-^ fetched during the last execu- tion cycle of instructions which do not write to the ohmmeter. A device which measures electrical resis- data bus. m f'^x'^^'^^"^ resistance is measured with a VOM poll. In programming, to repeatedly examine an ad- '™t-Ohm Meter) or multimeter which performs dressed location or to examine a series of addressed other functions besides resistance measurement. locations until a certain indication is given, e.g. pol- op code, operation code. The part of a machine lan- ling the disk controller data register for an MSB set guage instruction which specifies the command which indication. IS to be performed. The op code of each 6502 instruc- positive logic. A system of logical analysis in which the tion ISthe first byte of that instruction. high voltage state is considered to be true or one, and open collector. A class of TTL IC outputs which are the low voltage state is considered to be false or zero. tied only to an open transistor collector inside the IC. The Apple He and most modern computers use posi- Open collector outputs are useful for driving wire-OR tive logic. See negative logic. lines and interfacing to non-TTL devices. potentiometer, pot. A mechanically variable resistor. operand. The entity operated on by a machine language Typically, resistance will be proportional to the shaft instruction. In "LDA $00", the operand is the con- rotation of the pot. Apple He paddles are pots with tents ofmemory location 0, In "SEC", the operand is knobs on them. 6 Understanding the Apple lie retrace. In electron beam scanning across the face of a power supply. An electronic assembly which converts television or monitor picture tube, the very fast an AC (alternating current) line voltage to usable DC return of the beam from right to left during which (direct current) power. The Apple lie power supply the picture is blanked. See trace. converts household power to +12V, -12V, +5V, and RF modulator. A device which varies a high frequency — 5V referenced to ground. signal as a function of a lower frequency signal. See printed circuit card, PC board, A thin card nnade of modulate. an insulating material upon which electronic compo- nents are mounted. The component wiring is "print- ROM, read only memory, non-volatile memory, non- ed" on the board. The printing process involves start- alterable memory. A type of memory which the ing with a card completely coated with conductive computer cannot write to or otherwise alter. It holds metal, then etching away everything but the desired programs and data which are always available when conductive parts using photo-chemical methods, power is applied, such as BASIC and the monitor in program counter. A counter in a computer which con- the Apple lie. See PROM, EPROM. tains the memory address of the instruction being RWTS, Read or Write a IVack and Sector subrou- executed. The 6502 has an internal 16-bit program tine. The subroutine of DOS 3.2 and DOS 3.3 that is counter. called to read or write the data field of a floppy disk PROM, Programmable Read Only Memory. Read sector or to format a floppy disk. See DIIDD. only memory that can be programmed after it is manufactured. See ROM, EPROM. SECAM, SEquential Color And Memory. The televi- sion system used in France and some other countries. propagation delay. The time it takes for a signal or There are at least two versions of SECAM in use. See voltage to travel between two points. In logic gating, NSTC, PAL. the time required for an output to respond to a change in associated inputs. serial access memory, Memory which can only be accessed by sequencing through locations until the R/W line, read/write line. The signal by which the correct location is found. High speed magnetic tape MPU indicates whether it will receive data from or and bubble memory are examples of serial memories. tran.sfer data to an addressed device. The R/W line is See random access memory. best thought of as an extension of the address bus. See address bus, data bus. serial data transfer. Transferring data one bit at a time over a single line, as in the shifting of text pat- RAM, alterable memory, read/write memory. Mem- terns to the PICTURE signal. ory in which a computer can store or access data. random access memory. Memory in which any loca- serrations. Narrow horizontal sync pulses superim- tion can be accessed at will, such as the RAM and posed on the long vertical sync pulse in a video signal ROM in the Apple lie. See serial access memory. that prevent televisions and monitors from becoming raster. The pattern of scan lines produced on the screen horizontally unstable during the vertical sync pulse. See Figure 8,2, of a monitor or television. The 60 Hz Apple He raster contains 262 lines with no interlacing. simultaneous DMA. Direct memory access from a de- read cycle. A machine cycle in which the MPU receives vice other than the MPU which occurs when the data from the addressed location via the data bus. MPU is not communicating with memory and which does not slow execution of MPU programs. Video read-modify-write instructions. A class of MPU in- structions inwhich an operand is read from a mem- scanner access to RAM is an example of simultane- ous DMA in the Apple lie. ory location, then modified, then returned to the same memory location. 6502 read-modify-write in- SINGLE-RES mode. A term used in this book to refer structions include ASL, LSR, ROL, ROR, INC, and to the normal horizontal resolution (motherboard DEC. map only) display mode of the Apple lie. SINGLE- refresh. (1) The process of renewing data in dynamic RES mode is further categorized as the TEXT40, memory before it bleeds off. (2) The process of renew- LORES40, and HIRES40 modes. See DOUBLE-RES mode. ing an image on a cathode ray tube by rescanning the image before it fades away. SIP, Single In line Package, A type of electronic com- register. A temporary storage device which holds more ponent structure in which pins run lengthwise in a than one bit of information. It will normally serve single row. There are several SIP resistor networks in the Apple He. some special logic purpose. Examples include the 6502 internal registers and the data register of the soft switch. A conceptual switch that can be turned on Disk II controller. or off by programmed references to its on or off relocatable program. A program which does not have address. Soft switches are used for a multitude of to be in one specific memory range to be properly control functions in the Apple He including memory executed. It can be relocated to different memory management and display mode control. areas for execution. software. Programs and data stored in RAM and on resistance. The quality of hindrance of an electrical storage media such as disks, device to direct current flow. Resistance in a current source file. A source of data for data processing. In path may be controlled by installing fixed or variable assembly language processing, the assembly langu^e resistors. The unit of measurement of electrical re- source file is assembled into a machine language sistance isthe ohm. object file. Glossary 7 MOS devices like RAM, ROM. and the 6502, TTL special purpose computer. A computer whose function circuits are made using bipolar technology. cannot be changed by altering a stored program. The functions of a special purpose computer may be hard underware. A substitute for firmware used by some of wired, or the computer may execute fixed programs Apple's competitors to cut costs. stored in ROM. vector. An address or jump instruction stored in a stack. In microcomputers, an area of memory set aside memory location which contains program flow infor- for temporary storage and subroutine return link mation incase of certain events. An example is the information. In programming, the stack is conceptu- interrupt vectors stored in high memory in a 6502 based computer. ally similar to a stack of cards which can be drawn from or discarded to, one card at a time. vertical scan. The movement of the electron beam in a static memory. Memory which requires no refreshing television down the face of the CRT. In the 60 Hz to retain its data, such as the static ROM on the Apple He, vertical scan.262 horizontal scans occur during every Apple He motherboard or the static RAM on the IK auxiliary RAM card. video. A signal which can be used to control the energ\' status register. A register in a central processor which of the electron beam of a CRT. thus controlling dis- contains control information. In the 6502, the status play intensity, as in television video, radar video, and register contains indicators of the logical results of oscilloscope video. In television processing, the com- various executed commands. bination ofpicture, s.vnc. and color information is strobe. A short pulse that performs a triggering or commonly referred to as video. clocking action. Strobes in the Apple He include video scanner, video scan counter. Terminolog>' used RAS', CAS', the C040 STROBE', and the keypress by this book to describe a counter inside the lO'U that strobe from the keyboard encoder. controls memory scanning for video output in addi- SYNC (6502). A 6502 output signal that goes high scan. tion to controlling the television or monitor display when the 6502 is fetching an op code. The 6502 SYNC signal is connected to pin 39 of the seven volt. A unit for measuring voltage. Voltages of +12. -12, Apple lie peripheral slots. +5, and -5 volts are distributed throughout the television sync. That part of the television signal which Apple He. synchronizes the scanning of the electron beam in the voltage, electromotive force, EMF. A forte of nature CRT. It includes horizontal and vertical sync. which, when present, causes chai'ged particles to trace. In electron beam scanning across the face of a move; the force which causes electric current. \'ol- television or monitor picture tube, the scan from left tage is measured in volts. to right during which the the picture is displayed. wetware. A gra\' matter found within the craniums of See retrace. most humans. tri-state logic, three-state logic. A logic system in wire-OR, collector-OR. A low level OR gate formed by which there are three states: high voltage, low vol- tage, and high impedance. Devices connected to the wiring various signals together. The RESET', IRQ', NMF, INHIBIT', and DMA' signals of the Apple He Apple lie data bus have tri-state outputs so the var- are examples of wire-OR connections. Any peripheral ious devices are able to share control of the data bus. card may bring any of the wire-OR lines low, but troubleshoot. To isolate and repair the casualties in a cards not bringing a line low must present a high failed piece of hardware. impedance to that line. If no peripheral card is bring- TTL, IVansistor-TVansistor Logic. The logic family to ing a wire-OR line low. a 830(1 ohm motherboard re- which most general logic ICs in the Apple lie belong. sistor will pull the line high. Both the inputs and outputs of TTL chips are con- write cycle. A machine cycle in which the MPU sends nected to transistors inside the chip. As opposed to data to the addressed location via the data bus. appendix A References Apple Computer, Inc. Apple II Reference Manual. Jan. 1978. Apple Computer, Inc. Applesoft 11 BASIC Programming Reference Manual. 1978. Apple Computer, Inc. (Christopher Espinoza). Apple II Reference Manual. 1979. Apple1980. Computer, Inc. (orig-inally by Phyllis Cole and Brian Howard), The DOS Manual A ppic Computer, Inc. (Allen Wa.tson). Apple IIE.rtended HO-Column Text Card Supplemevtfor lie (Mil. 1982. Apple Computer, Inc. (Allen Watson). Apple He Reference Manual, (preliminary). May 1982. Apple Computer, Inc. (Allen Watson). Apple II Reference Manual for He Only. 1982. Apple Computer, Inc. DOS Progyaminvr'a Mununl for II, II+, He. 1982. Apple Computer, Inc. Reference Manual Addendum: Monitor ROM Listings for He Only. 1982. Apple Computer, Inc. BASIC Proc/ramming With ProDOS. 1983. Apple Computer, Inc. DOS f/.srrs' Maiinal for II. II+, He. 1983, Apple Computer, Inc. ProDOS Techi ical Reference Manual (for the Apple II family). 1983. Apple Computer, Inc. Apple He Reference Manual. Vol, 1 (preliminary), March 1984. Apple Computer, Inc. About Your Enhanced Apple He: Programmer's Guide (preliminary). Sept. 1984. Apple Computer PCS Division (John MacDougall). Haw to Get at the DVORAK (American Simplified) Keyboard in the Apple He. no date. Bishop, Bob. "Have an Apple Split." SOFTALK, p. 54, Oct. 1982. Brown, Chris and Maloney, Eric. "FCC Takes Aim Against RFI Polluters." Microcomput- ing, p.30, April 1981. Caffrey, Morgan P. "The New Apple He." Apple Orchard, p. 13, Feb. 1983. Ciotti, Paul. "Revenge of the Nerds." California, p. 73, July 1982. Derfler, April Frank 1981. J. "Trying to Live in Harmony with Harmonics." Microcomputing, p. 36, Devry Institute of Technology. Electronics Technology. Volumes 7 and 10, 1971. This text- book was the primary source of information relating to NTSC television. Fischer, Dan and Caffrey, Morgan P. "Go On and Interrupt Your Apple." SOFTALK March 1982 and p. 65, April 1982, , p 47 Fretwell, Cecil. "Setting I/O Hooks in ProDOS." Call-A.P.P.L.E., Gayler, Winston D. The Apple H Circuit Description. Howard p. 39, April 1984. W. Sams & Co Inc 1983 Lancaster, Don. TTL Cookbook. Howard W. Sams & Co, Inc. 1974. Leventh^al, Lance A. 6502 Assembly Language Programming. OSBORN E/MeGraw-Hill, References A-2 Mazur, Jeffrey. "HARDTALK." SOFTALK, p. 208, Sept. 1982. Concerns disk drives. Moore, Robin. "Apple's Enhanced Computer, the Apple He." BYTE, p. 68, Feb. 1983. MOS Technology, Inc. MCS6500 Microcomputer Family Hardware Manual. 1976. Osborne, Adam. An Introduction to Microcompiders, Volume U Basic Concepts. Adam Osborne and Associates, 1976. Osborne, Adam and Kane, Gerry. Osborne J^&8 Bit Microprocessor Handbook. OSBORNE/ McGraw-Hill, 1981, Sather, Jim, Understanding the Apple H. Quality Software, 1983. Sims, H. V. Principles of PAL Colour Television and Related Systems. Newnes-Butter- worths, 1969. Sippl, Charles J. Microcomputer Dictiormry, 2nd edition. Howard W. Sams & Co, Inc. 1981. Synertek, Inc. SY6500/MCS6500 Microcomputer Family Programming Manual. Aug. 1976. Synertek, Inc. Applications Information Am, SY6500 Microprocessor Family, Micropro- cessor Products. Oct. 1981. Tommervik, Al with Hunter, David and Durkee, David. "The Apple He: The Difference " SOFTALK, p. 118, Feb. 1983. Texas Instruments, Inc. Designing with TTL Integrated Circuits. 1971. Watson, Allen III. "True Sixteen-Color Hi-Res." Apple Orchard, p. 27, Jan. 1984. White, Robert M. "Disk-Storage Technology." Scientific American, p. 112, Aug. 1980. Williams, Richard. "How to Use the Hooks." MICRO, p. 30:7. Nov. 1980. Worth, Don and Lechner, Pieter. Beneath Apple DOS. Quality Software. 1981. Worth, Don and Lechner, Pieter. Beneath Apple ProDOS. Quality Software. 1984. Wozniak, Stephen, "The Apple II; System Description." BYTE, p. 34, May 1977. Wozniak, Stephen. "SWEET16: The 6502 Dream Machine." BYTE, p. 150, Nov. 1977. Wozniak, Stephen. Speech made at Applefest. Anaheim, CA, April 17, 1983. Component Data: Fairchild. MOS Memory Data Book. 1981. General Instrument Corp, Microelectronics Data Catalog. 1982. General Instrument Corp. ROMS, no date. Hitachi America, Ltd. IC Memories, no date. Jameco Electronics. 1984 Catalog, p 14. 1984. MOS Technology, Inc. 6500 Microprocessors. March 1980. Monolithic Memories. BIPOLAR LSI ]98i Databook. Fifth edition. 1978, 1981. 1983. Motorola Semiconductors. MC.U70 Floppy Disk Read Amplifier System. 1978. National Semiconductor. Interface Databook. 1980. National Semiconductor. Memory Databook. 1980. National Semiconductor. Logic Databook. 1981. National Semiconductor. Linear Datoftoo/c. 1982. NCR Corporation. NCR65C02. 1982. Rockwell International. R6500 Microcomputer System Data Sheet. Rev. 4, Nov. 1981. Rockwell International. R65C02, R65C102, and R65C112 R65C00 Microprocessors (CPU). Document No 29651N52. Rev 2, Feb. 1984. Synertek. 1981— 1982 Data Catalog. 1982. Synertek. 1 983 Data Book. 1982. Texas Instruments, Inc. The TTL Data Book for Design Engineers. 1976. United Technical Publications. IC MASTER. 1981. ^^h^. appendix B H'ademarks The following is a list of Registered Trademarks referred to in the text of Understanding the Apple lie. Apple Apple Computer, Inc. Apple II Apple Computer. Inc. Apple 11 Plus Apple Computer, Inc. Apple lie Apple Computer, Inc. Apple lie Apple Computer, Inc. Applesoft Apple Computer, Inc. CP/M Digital Research, Inc. Donkey Kong Nintendo HAL Monolithic Memories, Inc. PAL Monolithic Memories, Inc. Microsoft Microsoft, Inc. Softcard Microsoft, Inc. TRI-STATE National Semiconductor Corporation Z80 Zilog, Inc. appendix C 6502/65C02 Data In attempting to analyze Apple timing, it is dis- tional, and MOS Technology 6502 data sheets couraging tofind that the three 6502 nnanufactur- (Table C.l). Every attempt was made to make the ers have different specifications, even though the data in this compilation faithfully represent the MSC6502. R6502, and SY6502 should all perform data contained in each manufacturer's data sheet. identiealiy. It is even more discouraging to find followed by a layout of the author's that the specifications are well beyond the range Table C.l which showsis the execution periods of the various of typical operations, I therefore feel that Figure 6502 instructions CRible C,2). 4.5, which shows some measurements made of a Following the 6502 data is a partial reproduc- Synertek 6502 in an Apple He, is a more realistic tion of the NCR 65C02 data sheet. This data is indicator of 6502 timing than the manufacturers' reprinted with the permission of NCR Corpora- data sheets. Nevertheless, a partial reproduction tion, copyright 1982, all rights reserved. The of Rockwell International's data sheet is given 65C02 data sheet is included here because a grow- here. This data is reprinted with the permission of ing number of owners will be using a 65C02 in Rockwell International Corporation, copyright their Apple lie's now that Apple has released the 1981, all rights reserved. firmware upgrade. Following the 65C02 data Rockwell's timing specification charts are fol- sheet is a layout of the author's which shows the lowed by the author's compilation of the 2 MHz execution periods of the various 65C02 instruc- timing charts of the Synertek, Rockwell Interna- tions (Table C.3). C-2 Understanding the Apple lie R6500 Microcomputer System 0^ Rockwell DATA SHEET R6500 MICROPROCESSORS (CPU) SYSTEM ABSTRACT FEATURES The 8-bit R6500 microcomputer system is produced with M • Single ■*-^\/ supply Channel, SiHcon Gate technologv- '« performance spWfls are • N channel, $i)icon gate, depletion load technology enhanced by advanced system architecture. This innovative • Eight bit parallel processing architecture results in smaller chips - the semiconductor threshold • 56 Instructions is cost-eHectivitv System cost effectivity is further enhanced by • Decimal and binary arithmetic providing a family of 10 softv^are-compatible microprocessor • Thirteen addressing modes (CPU) devices, described in this document. Rockwell alio pro- • True indexing capability vides memory and microcomputer system- as well as low^-cost • Programmable stack pointer design aid& and documentation. • Variable length stack • Interrupt capability • Non-maskable interrupt R6500 MICROPROCESSOR (CPU) CONCEPT • Use with any type of speed memorv • 3bit Bidirectional Data Bus Ten CPU devices are available. All are software-compatible. • Addressable n^emory range of up to 64K byt^t • "Ready" input They provide options o' addressable rnemory, interrupt input, on-chip clock oscillators and drivers. All are bus2 0.8 Input Low '■'"'' =■ *o Voltage (ml Vdc *r*2 V^C + 0,25 04 Input Leakage Current 1. 'tsi (V.^ = 0 to 6.2SV, V^^ = 01 ^OH Logic (Excl, Hdv.S.O-l - 100 2.5 *r*2 too *o(in( - ^D - ^OL Three-State (Off Statel Input Current 10 IV.^^ = 0.4to2.4V, V(,j, = 5.ZSV) Data Lines - pA Output High Voltage Vdc Vdc "load ' -''°° *'*■''=■ ^cc SVNC, Data.AO-AIS.Bm, ■ * '^^' 4>y *, - Cin mW Output Low Voltage "load=^-S'^*<*'.V-*"^* MA SYNC. Data, A0.A15,R/W, *,.«, ^SS^^* Power Disiipation 800 1 and 2 MHi <=ou , - 700 3 MHz - c*, "'^ c 10^SS^ CapKjitance at 2S°C C*j 15 (V.^-0, f- IMHll '^^(in Logic *t l - 12 ♦j Data - *o(i A0A15.R/W,SYNC n) - - 15 - 60 NOTE IRQ a eo nd NMI require 3K pull-up resistor. pF SOiCll; ■*ill]fi« ^,^y&, 7 Unit ChvacWfjstic trws"fACC rtS Symbpt Thriw Tads _ _ _ - 255 - 110 - Rrt« EetLjp Tpone 140 140 Tha R^W HoldT 0.5 Min Min Mw Unit 480 15 Cytale Time 420 10 0,33 10 ni TPWH*! 240 160 rH ^ollnl '"°" Time 240 160 *3lln' "*Tinie 10 160 10 nt 430 4eo 25 *, Pul.e"'"' *i;lln( ""' f'I'Ti™- Width 23S tss ni 240 nf 0^ Pulse Delav Width «i ahd ^2 Between 0 0 0 35 ni <^y lb-2 Rise and Pail Time" NOTE • Measurod bcineen O.B and J.O poinu on luaviform load 1 30 pF + 1 TTL B^ ..tsrflSfi -a 6502/65CX)2 Data C-S lU ggggggggggggg gggggggggggSg r- 1^ (a I CO 1 ! i (0 qS^V i;j^ I I I :ql:^Uil31i:^lM (1> 0 fl a 4-1 0) > ■H £-1 E- IQ^-'Q I • CN CS I r tMfV t I t i |5t in IQ Iro Itas i^r-t \(Q rn imsm m w c « SC -H ro 0 0) IS) in c, C 4J b -rH S I 1 s QnH I --' — !< in ro — ' IcMpSii-HQininm J -~^ gii^irHi rHirHinl iSinr- |.H.-HrHll n ^ o ~-~> K in r^ ^ ^ t^ n rS a 8lO • ra s 0 f^ Tl Ul ■r-l m >• ^ '—*'-** Q Q ■'~^ ""^ -H iS > > • r>j D^-Oh (fi S ^ + I I +, C^) 0 00• s»• S P "^ rH tN rH CN rflO in rH i^ c > t:; +0 -P 0) • in 0 Q IT) in Eh > (U . (D ^q . +J D.4-> e-iJ > hJ > + "O p(i) 'd CJ +) CO ij :* E-t i-i HEh D Q C J3 rH CTJ • -H iJ M M a H M en ^ -O + -D -O Vi U (U DO) ^-,M (N M (N w M w « a W E-i g MW Sfe E-" Q E-i @ M ME 9 1 p U) r*0 R II Vj h S^ iH „ [/I £ X £ £ M § a- hP J S Q |h S m '0II13 >H (Tl m 3 73 W3 a 3 01 3(0 +J H 2 H K CM K Cu ni « 0 a (0 nj S) iTj d (1) s ■^ Eh p J cow 3S . . „ E-I to s (1) O (D ro 0 01 J OS ^^ S -H S S p B y y M tN +J M E-< in vfl r- 00 a) jiasQiSrHCMFiMSigss rt5 caS 5 TTL compatible input requests that an interrupt When a positive edge is detected, there is an initialization sequence begin within the microprocessor. The IRQ is sequence lasting six clock cycles. Then she interrupt sampled during 02 operation; if the interrupt flag in the mask flag is set, the decimal mode is cleared, and the pro- processor status register is zero, the current instruction gram counter is loaded with the restart vector from loca- is completed and the interrupt sequence begins during tions FFFC (low byte) and FFFD (high byte). This is 01. The program counter and processor status register the start location tor program control. This input should are stored in the stack. The microprocessor will then set be high in normal operation, the interrupt mask flag high so that no further IRQs mav occur. At the end of this cycle, the program counter Read/Write (R/W) low will be loaded from address FFFE, and pro GENERAL DESCRIPTION The NCR CMOS 6S02 is an 8bit microprocessor which is soft- ware compatible with the NMOS 6502. The NCR6SC02 hardware Interfaces with all 6500 peripherals. The enhancements include eight additional instructions, expanded operational codes and two new addressing modes. This microprocessor has all of the ad- vantages ofCMOS technoiogy: low power consumption, increased noise immunity and higher reliability. The CMOS 6502 is a low power high performance microprocessor with applications in the consumer, business, automotive and communications market. FEATURES Enhanced software performance including 27 additional OP codes encompassing ten new instructions and two additional addressing modes. 66 microprocessor instructions. T5 addressing modes. t78 operational codes. IMHz, 2MHz operation. Operates at frequencies as low as 200 Hz for even lower power NCR65C02 BLOCK DIAGRAM consumption (pseudo-static: stop during 02 ^'9^) Compatible with NMOS 6500 series microprocessors. 64 K-byte addressable memory. Interrupt capability- Lower power consumption. 4mA @ IMHz. +5 volt power supply, 8-blt bidirectional da!a bus. Bus Compatible with M6800. Non-maskable interrupt. All [IRES! 40 pin dual-in-line packaging. '"'' 8-bit parallel processing Decimal and binary arithmetic. Pipeline architecture. Programmable stack pointer. Variable length stack. OptionaMnternal pullups for (RDY, IRQ.SS, NMI and RES) Specifications are subject to change without notice. Copyright ©1982 by NCR Corporation, Dayton, Ohio, USA V,TN 6502/65C02 Data C-9 a Vdo NCR65C02 • ABSOLUTE MAXIMUM RATINGS: ( Vdd = 5.0 V + 5%. Vss = 0 V, Tft = 0° to + 7crc) RATING SYMBOL -0.3VALUE to +7.0 UNIT SUPPLY VOLTAGE TSTG -0.3 to +7.0 V INPUT VOLTAGE V OPERATING TEMP. 0 to + 70 -55 to + 1 50 STORAGE TEMP. ■ PIN FUNCTION PIN FUNCTION AdcJress Bus A0-A15 D0-D7 Data Bos Ready Interrupt Request " MLIRCYl' Memory Lock RD Non-Maskable Interrupt SYNC Synchronize HMi' Reset Set Overflow FffS* IMC No Connection R/WS0O0" Read/Write Vdd VDD Power Supply (+5V) VSS Internal Logic Ground Clock Input fll.02 Clock Output Vm "This pin has an optional internal pullup for a No Connect condition. > DC CHARACTERISTICS MAX UNIT SYMBOL MIN. i TYP. Input High Voltage V,L - V OoMN) Input High Voltage Vss + 2." V RES, NMI, RDY. 1 RQ, Data, S.O. -30 Input Low Voliaeje Vss + 2.0 - V +30 Codwi V RES, NMI, RDY, IRQ, Data, S.O. Vss +0.4 Input Leakage Current Vss -0-3 + 1.0 Vss + 0.8 (V,fj ^ 0 to 5.25V, Vdo = 5.25V) With pullups Un Without pullups Itsi Three State (Off State) Ifvput Current IV|N = 0.4 to 2.4V, Vcc = 5.25V) 10 Data Lines VOH Output High Voltage doH =-100 /: ADDR, R/W h-'R )C READ DATA s Bm« h-lr WRITE DATA > SYNC 1 ML ;£!: X ROY, FRq NMi, RES X j( SO 1 Note: All timing is referenced from a higii voltage of 2.0 volts and a low voltage of 0.8 volts. ■ NEW INSTRUCTION MNEMONICS HEX MNEMONIC oescniPTiON 3A 80 BRA Branch relative always IRelativel DBA Decrement accumulator [Accum) DA 1A INA Increment accumulator (Accum! PHX PHY Push X on stack [Implied) F=A 5A Push Y on stack [Impliedl PLX 7A PuH X from stack [Implied) 9C PLY Putt Y from stack [Implied) STZ Store zero [Absolute] SE Store zero [ABS, X] 74 STZ Store zero [Zero page) STZ Store zero [ZPG.X) 64 STZ IC TRB Test and reset memory bits with accumulator [Absolute) TRB 14 Test and reset memory bits with accumulator (Zero page) OC TSB Test and set memory bits with accumulator (Absolute) 04 TSB Test and set memory bits with accumulator (Zero page) ITIONAL INSTRUCTIC 72 HEX 38 MNEMONIC DESCRIPTION ADC AND Add memory to accumulator with carry [{ZPG)) 34 "AND" memory with accumulator HZPG)) BIT 3G Test memory bits with accumulator (ABS. X) m?C BIT Test memory bits with accumulator (ZPG, X) S2 eoR CMP Compare memory and accumulator !(2PG)) "Exclusive Or" memory with accumulator ((ZPG)i 12 Jump (New addressing mode) [ABS(IND,X)i LDA JMP Load accumulator with memory (IZPG)) F2 02 ORA "OR" memory with accumulator HZPG)] 92 STA S8C Subtract memory from accumulator with borrow i(ZPG() Store accumulator in memory [(ZPG)! *^''i»ii,tt - C-1 2 Understanding the Apple lie NCR65C02 ■ ADDRESSING MODES it establishes a destination for the conditional branch Fifteen addressing modes are available to the user of the The second byte of the instruction becomes the operand WCR65C02 microprocessor. The addressing modes are described in the following paragraphs: which s an "Offset" added to the contents of the pro- gram counter when the counter is set at the next in- struction. The range of the offset is -128 to -1-127 Implied Addressing llmplied] In the implied addressing mode, the address containir)g bytes from the next instruction. Zero Page Indexed Indirect Addressing [(IND, Xl] the operand is implicitiv stated in the operation code of the instruction. With zero page indexed indirect addressing (usually re- ferred to as indirect X) the second byte of the instruction Accumulator Addressing lAccum] is added to the contents of the X index register; the This form of addressing is represented with a one byte carry is discarded. The result of this addition points to a instruction and implies an operation on the accumu- memorylocation on page zero whose contents Is the low- lator. order eight bits of the effective address. The next mem- Immediate Addressing [Immediatel ory location in page zero contains the high-order eight With immediate addressing, the operand is contained in bits of the effective address. Both memory locations the second byte of the instruction; no further memory specifying the high- and low-order bytes of the effective addressing is required. address must be in page zero. Absolute Addressing f Absolute! 'Absolute Indexed Indirect Addressing [ABSIIND, X)] For absolute addressing, the second byte of the instruc- (Jump Instruction Only) tion specifies the eight low-order bits of the effective With absolute indexed indirect addressing the contents of address, while the third byte specifies the eight high-order the second and third instruction bytes are added to the bits. Therefore, this addressing mode allows access to the X register. The result of this addition, points to a memory total 64K bytes of addressable memory. location containing the lower-order eight bits of the effective address. The next memory location contains Zero Page Addressing [Zero Page] the higher-order eight bits of the effective address. Zero page addressing allows shorter code and execution times by only fetching the second byte of the instruction Indirect Indexed Addressing i(IMDI, Y] and assuming a 7ero high address byte. The careful use This form of addressing is usually referred to as Indirect, of zero page addressing can result in significant increase Y. The second byte of the instruction points to a mem- in code efficiency. ory location in page zero. The contents of this memory Absolute Indexed Addressing iABS, X or ABS, Y] location are added to the contents of the Y index regis- Absolute indexed addressing is used in conjunction with ter, the result being the low-order eight bits of the effec- tive address. The carry from this addition is added to the X or Y index register and is referred to as "Absolute, X," contents of the next page zero memory location, the and "Absolute, Y." The effective address is formed by result being the high-order eight bits of the effective adding the contents of X or Y to the address contained address. in the second and third bytes of the instruction. This mode allows the index register to contain the index or 'Zero Page Indirect Addressing [(ZPGII count ualue and fhe instruction to contain the base In the zero page indirect addressing mode, the second address. This type of indexing aliows any location refer- byte of the instruction points to a memory location on encing and the index to modify multiple fields, resulting page zero containing the low-order byte of the effective m reduced coding and execution time. address. The next location on page zero contains the high-order byte of the effective address. Zero Page Indexed Addressing [ZPG, X or ZPG, Y] Zero page absolute addressing is used in conjunction Absolute Indirect Addressing [(ABS)l with the index register and is referred to as "Zero Page, (Jump Instruction Only) X" or "Zero Page, Y," The effective address is calculated The second byte of the instruction contains the lomtorder by adding the second byte to the contents of the index eight bits of a memory location. The high-order eight register. Since this is a form of "Zefo Page" addressing, bits of that memory location is contained in the third the content of the second byte references a location in byte of the instruction. The contents of the fully speci- page zero. Additionally, due to the "Zero Page" address- fied memory location is the low-order byte of the effec- ing nature of this mode, no carry is added to the high- tive address. The next memory location contains the order eight bits of memory, and crossing of page boun- high-order byte of the effective address which is loaded daries does not occur. into the 16 bit program counter. Relative Addressing [Relative] Flelative addressing is used only with branch instructions; NOTE: * = New Address Modes 6502/65C02 Data C-13 NCR65C02 • INSTRUCTION SET - ALPHABETICAL SEQUENCE AOC AdfJ Memory to Accumulgior wJtrt Carry LDX Load Index X wth Memory AMD "AND" Memory with Accumulaiar LDY Load Index ¥ with Memory ASL ShitiOne Brt Left LSR ShifiOne Bit Right BCC Branch on Carry Clear NOP No Operation BCS Branch on Carry Set ORA "OR" Memory with Accumulator SEO Branch on ResuU Zero PHA Push Accumu^ato<■ on Stack SIT Test Memory BiTS with Accgmufator PHP Push Processor Status on Stack BMl Sramch on Result Minus 'PHX Push Index X on Slack BNE Branch on Result not Zero " PHV Push Index Yon Slack BPL Branch on Result Plus PLA PufI Accumufator from Stack 'BRA Branch Always PLP Pull Processor Status from Slack BRK Force Break ' PLX PuH Index X from Slack BVC Branch an Oyerilovw Clear ■ PLY Pull Index Y fram Stack BVS Branch on Otferflovw Set ROL Rotate One Bit Left CLC Clear Carry Flag ROR Rotate One Bn R»ghi CUD Osar Decimal Mode RTI Return Uom Interrupt CLI Clear IntetruptQi^bie Bit RTS Return from Subroutine CLV Clear OwrUow Flag SBC Subtraci Memory from Accumulistor wth Barrow CMP Compare Memory and Accumulator SEC Set Carry F!ag CPX Compare Memory and fndex X SED Set Decimal Mode QPy Compare Memory and Index V SEI Set Interrupt Disable Bit " DEA Decrement AccumuJator STA Store Accumulator in Memory DEC Decremeni by One STX Store Index X m Memory D£X Decrement Index X by One STY Store Index Y m Memory OEV Decrement Index V by One * STZ Store Zero m Memnry EOR "Exclusive- or" Memory wiih Accumularof TAX Transfer Accumulator to Iridex X • JNA Increment Accumuistor TAY Jfsmiir Accumulator to Index Y five rncrement by One ■ TRB Test anci Reset Memary Bi's with Accumulator (NX Increment Index X by One ' TSB Test and Set Memory Bii5 with Accumulator INY Increment Index V by One TSX Transfer Stack Pointer to fndex X JMP Jump to New Location TXA Transfer fndex X to Accumulator JSR Jump to New Location Saving Return Address TXS Transfer index X to Stack Pointer LDA Load Accumulator with Memory TYA Transfer Index Y to Accumulator Note: * - r^Jew Instruction > MICROPROCESSOR OP CODE ;pg TABLE "~ora" !P9 ASL ASL s ipg D 0 1 2 3 zp4 5 6 7 s 9 A B c E F D 0 BRK ORA ASL PHP ORA 0 ind, X zpg ORA !0g A abs abs abs 2pg 1 BfL ORA ASL CLC 1 ORA Upgl zpg, X Jljs, V ORA ROL X rel ind, Y ORA A ROL ab s AND abs ,ib5. JSR zpg imm AND abs ORA't TSB- "asl^ 2 abs AND X ind, aiT zpg AND ROL abs, X 2 A abs AND 3 BMl TRB* AND ROL SEC PHA AND BIT AND ROL 3 (Jpg) PLP ,ihs. X rel ind. Y X A abs. X AND-t ;pg- ;P9. X abs. X zpg, X Sl)5, V 4 RT( EOR EOR EOR JMP TSB- EOR LSR 4 ind, X zpg iP9 LSH A dhs ,ibs abs rpg LSR rNA' 6 BVC rel EOR EOR LSR EOR BIT-tTR B- EOR Ji)s. X 5 mtJ, Y iP9, X zpg, X PLA RTS EOR-t - ADC 6 ADC BIT ipg ADC zpg ROR abs. imrn Y ADC ROR AOC X LSH iibs 6 ind, X CLI abs. zpg A (absl abs abs AOC OEA- 1 evs ADC ROR ADC abs (irid.XI ROH 7 llPSl JMP 3»i. X rel md, Y ADC-t al)5, Y PHY- ROR X alas. ipg, X ipg. X zpt>. X SEI 6 STA TXA I 3 ind, X abs STZ- STA zpg STX irtirri abs abs JMP-t STX 9 BCC BRA* 9 STA ipg TYA DEY TXS !P9STZ- STA STY abs, X abs. X rs ind, Y ab s STA STA-t log. X abs ;pg. X 3b5, Y STA A LDY STYSTY' STX zpg LDX A imm LDX STA TAX LDX LDA X nd, zpg ZP9, Y TAY imfTi LDA PLY- abs BCS zpq LDA a LDA LDY LDA LDX LOX B re, LDY ind, Y abs. LDA X LDA-t LOV LDAY abs, LDA c cpy ind, X 2pg, X CPY zpg, X CMP DEC Y zpg. CLV 3bs. X □EC abs. y C ifnm CMP zpg BIT- TSX LDY abs abs abs iitim CPY BNE D zpg DEC INY CMP 0 CMP Y md, <'pgi CLO CMP rel zpg CMP CMP STZ-abs, X abs, CMP-t zpg, X DEX DEC X STZ- E zog, X jbs, Y CPX imm SBC SBC INC r^x SBC SBC irjc E ind. X abs abs abs imm CPX CPX P BEQ rel SBC sect SBC INC SBC NOP CMP INC abs. X F ind, ¥ zpg, X SED abs, Y 0 1 2 3 A 5 ZP9, X 6 ? a 9 PHX- A B C aOs,0 X ^ F Note; SBC * ' New OP Codes Note: 1 t = New Address Modes PLX- C-44 Understanding the Apple He NCR65CQ2 OPERATIONAL CODES, EXECUTION TIME, AND MEMORY ABS REQUIREMENTS A8S n < PROCESSOR IIND. ~ n * PAGE 2Pf3 RELA IMME ABSO iERt 1 IM IIND c izPGi STATUS cooes AND ACCU M PLIE 3 X) V TIVE (ABS . UNO X ZPG. V ' 6 6 4 3 3 1 n E LUT( X ABSY ADC DIAT OP * N V . e D 1 I c IE r6 n « OP QP h MNE OPERATION *3 OP DO * Of n IN V . f DP n 39 60 * OPn 2 N . . IZC WNE AS I. ADC OP n 1 OP n # OP n * OPn OP n6 2 71 * 61 5 2 75 4 2 7D4 2 3 79 4 3 72 5 AtM*C*A £1.31 ! 6D 4 3 65 3 21 6 *0P n *0P FO N 2C AND AAM-A ASL 29 2 2 2 31 S n 2 *0P 4 3 JI S ecs £11 69 5 2 2D 46 3 25 3 2 34 4G 2 OE 1 16 3 (B-^ «•<> £11 3 £16 5 2 OA 2 30 4 90 2 2 see Branch .ICO £11 KC 8CS granch il CO £71 2 1 BEO Bfaftch.(Z=l £71 sea BIT A A U 14. 5t as 2 2 2C 4 3 24 3 2 34 4 2 3C 4 3 BIT Branch il NO £71 30 60 BMI 8VS BUI BNE afL Br^rtChilZ^O Bfancn.lN-0 131 131 10 "■•»,■. '. 'i '. BNE BPL Branch A^wayt 12) SO BRA BRA ■ 11.. BBK Break 00 7 1 BRK BVC Branch if V=Q 121 .00 6VC 4 ; BVS Branch .IVM 121 70 CLC 0*C IS 2 1 CLC 0 CID 092 1 ■ . 0 0. -. .. 0*0 CLD iiS 2 1 CI 6 3 09 CLI O'l 03 5 CLI 1 CLV CH/ Aa *vM 111 EO 22 2 CD 4 3 C5 3 2 C9 2 D1 5 2 D5 4 2 DO 4 3 N IC CMP CMP X M DE6 N ZC CPX Z EC 4 3 E4 3 2 N J C CPX DEC Y M 06 6 CO 2 2 CC 4 3 C4 3 2 CPY 3A 2 1 CA2 N^ . . Z DEA DEA A 1 'A DEC M 1 -M 111 CE 6 2 2 3 3 C6 5 4 , 1 FE 6 N 2 DEX DEX X 1 ' X INA 49 2 88 3 P6 6 (y . . . 5 DEV y 1 -V lA 2 41 & INC DEV 84 4 2 N ..... 2 . EOR 2 40 4 3 45 3 2 2 515 2 &5 4 2 ^ &D 4 3 59 A y Al *A 65 5 EOR EE $ EB 2 INA A r 1 *A N . . . 2 . INC M . 1 -"W 111 3 E6 5 2 2 3 NN . . . 2Z .. CPV IhlX 1 INK X + 1 *X Y * 1 -Y 1 N Z INY INY 4C 3 3 7C 6 3 Al 6 Jump lo now lot EC 6 3 A9 2 JMP JSR Jump Su&fOuline 20 36 33 A5 1 ce 2 3 B9 LOA M-A 111 A2 2 2 AD4 3 A6 3 2 2 Bl 6 3 4 2 N Z . JSR LDA LOK M -X 111 SO 2 2 AE 4 2 2 85 4 4 ae 4 BJ 5 N - . Z . LDX IE 6 M-V [11 2 AC 4 3 A4 3 3 3 Bt:4 3 N ..... Z . LDV LOV 56 6 LSfl D -[? *-Lv: 111 3 46 5 1 S6 6 2 BD 4 3 13 6 2 4A 2 3 19 0 z c JMP □9 2 EA 2 1 NOP PC . 1 -PC NOP PLA ORA 01 5 A V M *A [11 2 OD 4 3 05 3 2 3 115 2 4 PHA 10 4 PHX PHP A-M, SI'S 4a 3 1 1 16 4 PHA P*Mi S 1 -S OB 3 1 PHP DA 3 1 rt ..'.'.'. z \ PHX 5A 3 1 X "M^ S 1 -S PHY v*Mj 5 1 -S 1 fHY PLA S • 1 ■ 5 M, • A 63 4 1 N . . - . , z LS« PLP 28 44 FA N V 1 0 1 ZC ORA S^ 1 'S M^*P PLF PLK 1 nOL S. 1-S M,»X 76 6 N Z - PLX PLY S+ 1 -S Mj^*v TA d 1 N . . Z ROL PLY JE e 366 26 5 2 2A 3e 6 3 .(. tl-itl-' III 2 1 36 6 2 N . Z C BIS RQR EE e 7E 6 F2 5 i.:c|.;. (1- 111 2 6A 2 1 2 3 N . . . Z C RTI Reiurn liom Inter 4D S 1 El 6 N V . 1 D 1 Z C HOft BTI RTS 3 F9 RAtitrn l*oni Srjbr £9 2 60 52 1 FD4 fa SBC 2 ED 4 3E5 3 IB 2 3 Fl 5 A M C'A It, 3! 2 2 F5 4 2 4 S 3 N V . . . . Z C sec SEC 38 2 1 1 -C . . . 1 SEC Bl 5 SED 1 -Q 5E 1 »l . . . 1 . SEI STA 3 95 3 2 A *M 2 95 4 2 9D 5 3 99 5 J 92 5 3 ... STA SD 4 AA7 2 91 6 X *M 3 BE 3 3 9B 4 7 STX Y+M STY BC 4 3 2 SE 4 TAX st; 33 34' 64 33 7 74 4 2 9E 5 3 STZ OQ-M 9C 4 AS 2 N ..... Z SED TAX A'Y 94 4 STX TAV IC 6 1 N Z 3 14 5 8A2 STY TRB TSB A/\M*M £il| 1 TRB A V M * M 14] OC 6 3 04 5 2 TSX s-x TSB 1 TXA M ..... Z - T5X TXS X -A 8A 2 1 X -5 9A 2 1 A . . . , Z TXS TVA TAV Y*A 98 2 1 J 2 TYA TXA Notes Index X 1. Add 1 to 2. Add 1 to it page bpurdary is crossed, Add And n No. Cycles ';,« if branch occurs to same page- Index Y Sublract AiJd 2 to 0 No. evtas it branch occurs to ditfereni page Accumulator Add 1 to if decirvial rnode. Memory per etteciive address 43. VV bit equ bit equals memorv bit 6 prior to execution. Ms Memory per stack pointer Mg Men^ory bit 6 Exclusive or M7 Memory bit 7 N bit equals memory bit 7 prior to execution. The immediate addressing mode of the SIT innruciion leaves bits Or 6*7 (V & N) in the Procewof Status Code Register unchanged. i^w f\M .1 .t^^/Hi^ 6502/66C02 Data C-15 Table C3 65C02 Instruction Ex»ciiflon Periods In Machine Cycles. ABS IHM REL ABS 0PG ABB IMP ACC 0PG 0PG 0Pa ABS ABS IND IND IND IHD IHD RRr. X Y X Y X 0PG Y 0PG X 5+p M)C AND CMP EOR ' 3 4 4 6 5 LDA ORA SBC »** 1 " ASL LSK ROL BOR 2 5 6 6 DEC IMC 2+p BBRn BBSn**** •* BCC BCS BEQ BMI BNE BPL BVC BVS BRA .. CLC CLD CLl CLV 2 MX DEY INX INY 4* NOP SEC SED S£I TAX TAY TSX TXA TXS TYA 4* BIT 2 3 4 4 6* BRK 5* 7 CPX CPY 2 3 4 JMP 3 e 6 JSR 6 LDX 2 3 4 4 1 LUY 2 3 4 4 PHk PHP PHX PHY 3 PLA PLP put PLY 4 4* S RMBI) SMBn**** I-— ■ RTI 6 6 RTS STA 3 4 4 5 5 6 b 5 STX > 4 4 4* STY 3 4 4 STZ 3 4 4 5 4* 1 TRB TSB 5 6 NOT£b: * +1 cycle if indexing crosses page boundary. ** p=0 if branch does not occurs p=l if branch within page occurs. p-2 if branch across page boundary occurs. *** Add 1 cycle to AQC ana SBC if decimal mode. »**» BBRn, BBSn, RMBn, and SMBn instructions are available in Rockwell 65C02 but not NCR 65C02. Boldfaced type inaicates difference between 65C02 and 6502. Unused op codes: 502, $22, S42, ¥62, 582, SC2, SE2 => 2 bytes, 2 cycles 5X3, $XB => 1 byte, 1 cycle 5X7, 5XF => 1 byte, 1 cycle (NCR only) 544 »> 2 bytes, 3 cycles 554, 5D4, SF4 => 2 bytes, 4 cycles 55C «> 3 bytes, 6 cycles $DC, SPC => 3 bytea, 4 cycles *Sjift appendix D BASIC Program Listings 5.9. The following pages contain the BASIC program listings which produce Figures B.8 and BASIC Program Listings D-2 RW REM RBI HIRES MEMORY MRP - DISPUYED SCAN ONLY RW RBI DIM HXS(IS) "3", "4", "5", "6", "7" 9","A","B","C","n","E","F" DATA "3","1","2 FOR A = a TO 15: READ HXS(A)4 NEXT A TEXT : HOME TOP SCREEN/ MIIIDLE SCREKN/ FIRST 40 SEirONn 40 PRINT " BOTTOM SCREEtl/" THIRD 40 PACE 2 LIN# PACE 1 UANCr LINI PAGK 1 RANGE PRINT " PACE 1 LINI PAGE 1 RANGE K REM 91 REM PAGE 1 RANGE" UNUSED B" 1C0 FOR A = e TO 7: TOR n = + H * 1824 + 8192 TO 7:PPiSE - 110 LNS = "S":PEC = BASE GOSUB 5000: REM GET PAGE 1 HEX 190 Rra 191 REM 200 DECS = STRS (BASE): IF LF.N (HIKS) 5 TIIKM LNS = LMS + 210 LNS = LN5 t " " + DECS + " S" 220 DEC = BASE + 8192: OOSUB 5OB0 : REM GET PAGf 230 LNS = EN$ t " " + STRS (DEC) t " " 290 REM 291 REM 380 SCAN = B * A t R: GOSUQ 6800 RF.-^ GET SCAr; NLIMREP 310 DEC = BASE: GOSUB 5(?S0 320 LNS = LNS t "-S" 340 DEC = 330 BASE " * 39: GOSIIR 5000 LNS + LNS REM = 390 391 REM * 64 400 ■■ SCAN ■ : OOS(.IE I snas) SCAN = 4K: GOStJR 5003 410 RBC ' EASE + 420 UJS = "-$" «0 440 dk; LMS == " LNS + ' 79: GOSUB 5000 BASE + « 490 REM 491 LN$ + ' RIM ^ SCAN 500 SCAN = ; GOSUR eonfl 510 1- 64- 5000 BASE + 80: GOSUB 520 DEC = '-S" LNS = 530 BASE + + ' 119: 1 COSUB 50«« LNS 590 DEC REM = 591 609 RKM 610 LNS = 120; LNS + ' '-S" : GOSUB 5000 BASE + 620 DEC = LNS = 127: 630 LNS BASE t+ ' : GOSUB 5000 640 DEC 650 PRINT= LNS: NEXT B: NEXT A PRIOT ; PRINT 660 PRINT "FIGURE 5. .a - HIRES DISPLAYED MEHORY WP. PAGE 1 AND PAGE 2 ARE EACH WDr !.:P OF 64 12R-nY7 670 GST REM BS: END 409^ 4091 RZM S" 4092 REM 4093 REM REM SUBROUTINE 5000 (CONVERTS THE DECIMAL ADDRi 4094 HEXADECIMAL AND iCONCATINATES THE 4095 REM HEX numb: 4096 REM 4097 REM 50m H4 = DEC / 4n96:He cosuR 5000; GET a; 4C1t? REM ******************** '\?\ PRINT ; PRIST : PRINT TA" ( llil 'VkrIICAI. W.nNKlHf: PIlHinil (WL)"; DPINT ; PPIMT 413 CCStJB 'lOOa 420 FOP A = 0 TO 7: FO? P. = 0 TO 7:|JASF ' A ■ 12S t " * 1074 t R1L2 4 33 GOSUB man 4<3 NFXT P: NFXT A 4''itl FDR B = 2 TC 7:HASF = 92l!B + P, * 1024: PE.-: 7*12R>8312-m* 1IS24 46(1 GOSUB IHBH 47(1 NEXT n 4Sv' OnSUP SaOO; GET AS 499 ENn 1808 REM lnP2 HEM PRIM f, LINK 1984 RF.M IflKl LNS = "":SCAN = SCAN + 1 : IE SCAN < 111 THEN I,NS = EN.S * " " 102C IF SCAN < 180 THEM LMS = LNS + " " 1325 WIS " LNS * STRS (SCAN) + " " 103(1 WW, = BASF - 24: IF IKT (HBL / I2S1 < > It.T (BASF / 128) THEN HBL = HBL + 12R 1048 DEC - HEL: GOSUB 3000: REM TO PAGE 1 1050 DBC = HBL * 8192: GOSUB 30OB: REM no PAGE 2 106C SYMBOLSS = "t++t* + f t + **+ ": IE SCAN > 223 ANI5 SCAN < 228 THEN SVMBOLSS = "»t«»»*lf »»•»• " 1365 LNS = LMS + "*t + + ***4-t«(|H" t SV.MDOLSS 1078 DEC = BASE: GOSUB 300K: REM ttO PAGE 1 1088 OEC = BASF + S192: GOSUB 3800; F!F.>1 00 PACE 2 1098 SYMROLSS - " + + f +■+++++++++■+»■++ +t + t^■tt++^■ + ^ + tf f+t+++++" UaC IF SCAN > 223 AND SCAN < 22S THEN SYMBOLSS = "tttti Kim tt»«#*«imti#IK*t»t##t»»f »##tt»" 1118 LNS = LNS + SVMBOLSS: PRINT LMS 1128 RETURN 3008 REM 3002 REM GET HEX t. DBCIMAL STRINGS 3004 REM 3005 H4 ' DEC / 4H96:H4» = H4 3016 K3 = (H4 - H41S * 16:H3% - H3 3020 H2 = (H3 - H3%1 * 16;H2i = H2 3030 HU = (H2 - H2%) * 16 + .6 3040 LNS = LNS + "S" + HX5(H4%1 + HXS (H3*) t HX5 (H2») + HXS(H14) + " " 3050 DECS = STRS (DEC): IP LEN (DECS) < S THEN LNS = LNS + " " 3060 LNS = LNS + DECS + " " 3070 RETTURN 4000 REM 4002 HEM PRINT HEADINGS 4084 REM 4010 4815 PRINT " PRINT HORIZONTAL BLANKING (HBL) HORIZONTAL DISPLAY ENABLE" 4023 PRINT "LINE 11111111 11111111111111U222S22SJ" 4030 4843 PRINT "NUH RETURN PAGE 1 PAGE 2 0012J456789A8CDEF91234567 PAGE 1 PAGE 2 [)123456739ABCDEF01534S6789ABCDEF0123«S67' 5000 REM 5002 REM PRINT FIGURE NUMBER 5004 REM 5005 PRINT : PRINT 5010 5020 PRINT "FIGURE 5.9 - THIS HIRES SCANNING MAP SHOWS THE ADDRESSES SCANNED (XIRING DISPLAV PESIODS AND BLANKING PERIODS." HETOHN Figure D2 BASIC Listing: Program that Produces Hgure 5.9. appendix E A Logic Circuits Primer Bits of information in a computer are generally This AND function is identical to the 6502 AND represented by voltages. In positive level logic like instruction, except that the 6502 instruction is that used in the Apple, a high voltage (about 3 performed on eight bits simultaneously and is log- votts) is considered to be true, and a low voltage ically equivalent to eight 2-input AND gates. (about 0 volts) is considered to be false. The elec- A way of demonstrating a logic function is a tronic circuits in the Apple are designed primarily truth table. The truth table shows the state of an to treat signal voltages as true or false indications output for every possible combination of inputs. and to process them logically. In studying the The true state can be represented by T or 1 or H Apple, it is advisable to concentrate on the logical (for high assuming positive logic), and the false function of the components rather than their elec- state can be represented by F or 0 or L. We will tronic function. use H and L because this usually eliminates possi- The most basic functional building blocks are ble ambiguities. The truth table for the positive simple logic gates. For example, a 2-input AND logic AND gate is; gate will bring its output high if and only if both INPUT A INPUT B inputs are high. In other words, both input A OUTPUT AND input B must be true if the output is to be L L L true. The two input AND gate is represented in L H L logic diagrams as follows: H L L H H H INPUT A This clearly demonstrates that both inputs of the positive logic AND gate must be high before the OUTPUT output will go high. Table E.l shows the truth table, INPUT B schematic representation, and equivalent 6502 in- struction, where applicable, of some simple logic gates used in this book. E-2 Understanding the Apple lie actions, then the actions all occur simultaneously The little circles on the gates represent the con- This clockpulse synchronization is common to ali cepts of inversion and active-when-low signals. digital computers. Certain devices react to the The two concepts are closely related and some- clock. Other devices react to those clocked devices times impossible to separate. Inversion is the pro- cess of turning a signal into the logically opposite and so on. After a given period of time, all reac- signal. When a signal is low, its inversion is high, tions are complete and the logic signals are all and vice versa. When examining a logic gate, the stable, waiting for the next clock. The computer absence of circles can be read as active-when-high thus operates one cycle at a time. and the circles can be read as active-when-low. As an example of clocked operation, Figure E.2 For example, the NAND gate has a circle on its shows a logic function similar to the 6502 AND output, meaning both inputs must go high to make instruction. In the AND instruction, the value in the output go low. This can be stated in a second the accumulator is ANDed with a different value way. If either input goes low, the output will go to get the new accumulator value. In Figure E.2 high. This results in a second way of representing the fiip-flop represents one bit of the accumulator! the NAND gate, as an OR gate with little circles When the flip-flop clock rises, the flip-flop goes to on the inputs. The circles take a little getting used a state determined by its old value ANDed with a to and are used in some pretty unusual ways in second value. some drawings. Just associate the circle with the Most logical circuitry is made up of some com- word "low" and you should get the message. bination ofsimple logic gates and flip-flops or The tri-state amplifiers of Table E.l represent a their equivalents inside an integrated circuit. In different sort of logic device. In addition to the nor- modern computers, many complex functions are mal binary states of high and low voltage, the tri- available packaged in integrated circuits. Typical state device has a third state, high isolation or high of such complex functions are comparison, count- impedance. The line coming in from the side is the ing, coding, decoding, and shifting. Even more output enable line and it controls the isolation. When complex are the functions of chips like the 6502, the output enable is not active, the device is isolated RAM, ROM, the MMU. and the lOU in the Apple from the output line, so another device can control He. A good way to familiarize yourself with the the output line. In electronic terms, the device pre- variety of logic functions available is to peruse the sents ahigh impedance to the output line. In the data books published by manufacturers. Of par- truth tables ofTable E.l. the high impedance state is ticular help in the Apple is a TTL data book, TTL represented by a "Z". A more detailed discussion of (Transistor Transistor Logic) is the name of the tri-state logic is contained in the chapter on bus logic family to which most of the Apple's general structure. purpose chips belong. National Semiconductor is a A building block of equal importance to the logic company which is very good at making their data gates is the clocked flip-flop. This is a 1 bit storage books available to the public at reasonable prices, device which will respond to its logic inputs when it Their TTL data is contained in the Logic Data- senses an active transition on its clockpulse input. book, priced at $9.00 as of March, 1982. Books can Figure E.l shows a diagram of a D type flip-flop and be obtained by writing: its truth table. The flip-flop shown is clocked by a low-to-high transition of its clockpulse input, and is National Semiconductor Corporation like the 74LS74 flip-flop pictured in Figure 6.13. ATTN: Literature Distribution MS/14208 2900 Semiconductor Drive The Q output will follow the D input every time the Santa Clara, CA 95051 clockpulse rises, and the Q' output will be the inver- sion of the Q output. The CLEAR and PRESET Understanding the Apple He uses logic equations inputs cause the flip-flop to change states without to describe the logical makeup of certain signals. requiring a clock, and actually override the clocked A typical logic equation is D input. Bringing PRESET low forces Q high and Q' low. Bringing CLEAR low forces Q low and Q' GR = (TEXT + MIX • V4 • V2)', high. which is equivalent to GR = NOT (TEXT OR (MIX The clockpulse adds synchronization to logic. If AND V4 AND V2)). The dot represents the AND the same clockpulse triggers a hundred different function, the plus sign represents the OR function, ■ i^JiiL- A Logic Circuits Primer E-3 Table E.I Basic Logic Gates. REPRESENTATION SECONDARY TRUTH TABLE 6502 NAME REPRESENTATION B A OUT EQUIVALENT AND L L L AND XXXX A- S L H L H L L B- >-OUT H H H JZ^~^OUT on L L L H L H ORA XXXX H L H bT^"'' H H H NANO B^^ >-0^T L L H AND XXXX L H H EOR «$FF H L H bI y^^T H H L NOR B^ >-OUT L L L H H L ORA XXXX EOR #$FF H L L bJZX"'" H H L b:: >- EXCLUSIVE L L L EOR XXXX OR L H H H L H B^r>- H H L AMPLIFIER L L NOP H H A-[>^OUT A-c^>o-OUT INVERTER L H EOR #SFF A -< ^^>^ OUT H L A-^^;>o-OUT TRI-STATE 8 L L Z AMPLIFIER L H 2 HIGH H L L ENABLE A-[j>-OUT H H H TRI-STATE B L L Z INVERTER L H Z HIGH H L H ENABLE A - px:^ OUT H H L B TRI-STATE L L L AMPLIFIER L H H LOW H L Z ENABLE A - "^y^ OUT H H Z TRI-STATE B L L H INVERTER L H L LOW H L Z ENABLE A~[^]>o- OUT H H Z ''ffii.: E^ Understanding the Apple He TRUTH TABLE OUTFITS INPUTS PRESET CLOCK 0 0 Q CLEAR L H X X H L H L X X L H L L X X H H H H + H H L H H + L L HLD H HLD H H L X HID H H H X HLD \ TYPICAL OPERATION CLOCK D t CLEAR PRESET Q Figure E.I A D-Type Flip Flop. Q' and the prime symbol represents the NOT or generation in a concise way. No algebraic manipu- INVERSION function.* This selection of symbols lations are described, and none are required on the makes the equation look like an equation of com- part of the reader. mon algebra, and it's no accidental coincidence. The manipulation of such equations has parallels ♦In representing the NOT function with a prime symbol, this in the field of algebra and is, in fact, referred to as book is following the sensible lead of the Apple II R^erenee Boolean algebra, after the symbolic logic pioneer, Manual for He Only. The more common convention is to over- George Boole. score the term or terms to which the NOT function is applied. The overscore is not a particularly workable representation Other functions besides AND, OR, NOT, and because it is not a common typographical symbol and, more parenthesis grouping can be represented in logic importantly, there is no code for it in standard computer text equations, but only these basic functions are rep- coding systems such as ASCII. Engineering and manufactur- resented inlogic equations in this book. The pur- ing printouts normally use an asterisk or prime symbol after a pose in using such equations in Understanding the term to which the NOT function is to be applied. Apple s.hould be commended for taking the lead in using this notation in Apple Ik is only to describe some details of signal published documents. ■<,ff- -'*^N —Z A Logic Circuits Primer E-5 D COMPARISON INPUT 0 Q n npK to > CK 1/8 OF THE ACCUMULATOR Figuie E2 The Circuil Equivalent of the 6502 AND Instruction. "■^jj . •^••i?'»R appendix F A Number System Primer In our daily lives, we represent numerical quan- and the information as to whether the switch is on tities in the base 10, or decimal, numbering sys- or off is a bit of information. The simultaneous tem. For example, by 359 we mean the sum of 9 x states of eight binary switches can be combined (10 EXP 0) plus 5 X (10 EXP 1) plus 3 x (10 EXP into an 8-bit binary word such as 10011110. Be- 2). This use of the decimal numbering system cause of the 2-state nature of digital computer gives us some unusual biases that would occur building blocks, digital analysis and design has only to mathematicians if we used a different base been performed since day one using the base 2, or for our numbering systems. For instance, we place binary, numbering system. In this system, there special significance on numbers like 1,000,000 (10 are two digits— 1 and 0. The binary number 110 EXP 6) but not on 2.985,984 (12 EXP 6, equal to represents the sum of 0 x (2 EXP 0) plus 1 x (2 1,000,000 in the base-12 or duodecimal numbering EXP 1) plus 1 X (2 EXP 2), which is equal to 6 in system). Mathematicians have studied number sys- decimal. tems for years, but now, because of the growing Actual performance of binary arithmetic is very influence of computers, knowledge of numbering unwieldy, particularly if you consider fractions. systems other than base 10 is becoming very com- Addition and subtraction of 6502 addresses would mon indeed. You see, the electronics of digital computers is require 16 digits. For example, subtracting dec- imal address 35000 from 35003 looks like this; based on hundreds of thousands of 2-state, or binary, electronic switches which can be on or off. 1000100010111011 The on or off state of each binary switch can be - 1000100010111000 represented numerically as a ONE or a ZERO, 11 .^^4 A Number Systems Primer F-2 If that looks clumsy, you should try multiplyin tween binary and hexadecimal, the binary num- J.40 A ^r* i 4 g 11110111 ber is divided into groups of four digits starting from the right: X. 10001111 11110111 1000 1001 nil 1001 = 89F9 (base 16). 11110111 11110111 6502 programming convention calls for use of 11110111 the hexadecimal numbering system for represent- 11110111000 ing addresses, machine language code, and much data. Convention further calls for preceding hexa- 1000100111111001 decimal numbers with a dollar sign ($89F9) and binary numbers with a percent sign (%10001001), To prevent carrying out operations like this, com- to distinguish them from decimal numbers. Fol- puter programmers use other number systems lowing convention, the Apple monitor represents based on powers of two, such as octal (base 8) and all numbers in hexadecimal. As a result, some hexadecimal (base 16). Arithmetic is much easier skill in hexadecimal arithmetic and hexadecimal/ to perform in these systems and conversion to and decimal conversion is very desirable for Apple from binary is so easy that you can do it on sight programmers. In addition, the well rounded com- with a little practice. For example, the above puter programmer will be familiar with the bi- product can be read as hexadecimal 89F9 or octal nary and octal systems. 104771. Here are two numerical facts of life about 6502 Conversion between binary and octal consists of based microcomputers like the Apple. First, there dividing the binary number into groups of three, are 16 address lines connected to the 6502. 16 lines from right to left: can be in 65536 different possible combinations of 1 000 100 111 111 001 = 104771 (base 8) states (0—65535, $0— $PFFF, or %0— %1111 1111 nil 1111). Second, there are eight data lines con- These patterns of three digits can each be con- nected to the 6502. Eight lines can be in 256 dif- verted toone of eight octal digits from Table F.l. ferent possible combinations of states (0—255, With exposure, these patterns become very famil- $0-$FF, or %0-%llUllll). These numerical fea- iar. As you would guess, there are eight symbols in tures of the 6502 account for some limiting num- the octal system, 0—7. bers which occur in the BASIC language like The hexadecimal system has 16 digits, 0—9, A, 65535, 255, 32767, and 127. B, C, D, E, and F. The use of letters to represent Addresses are normally referred to in hexadeci- numbers is sometimes confusing, but that's the mal in Undcrsta ridhifj the Apple lie. This is because convention we're stuck with. When converting be- the hexadecimal representations make sense and Table F.l Number System Equivalent Representa ions. DECIMAL BINARY HEXADECIMAL OCTAL 0 0000 0 0 1 0001 1 1 2 0010 2 2 3 0011 3 3 4 0100 4 4 5 0101 5 5 6 0110 6 6 7 7 7 0111 8 1000 8 10 9 9 11 1001 12 10 1010 A 11 1011 B 13 C 15 14 12 1100 14 13 1101 D 1110 E 16 15 F 17 1111 "*._ fe^>A M Understanding the Apple He If this is your first exposure to number systems are easy to remember. Numbers like $10000, $C000, then you have just scratched the surface. It is and $2000— $3FFF are much more to the point than highly recommended that you spend some time 65536, 49152. and 8192-16383 when representing with mathematics or computer arithmetic courses the number of Apple addresses, the start of I/O solving problems and familiarizing yourself with addressing, and the address ran^e of the HIRES this sort of numerical manipulation. You need to PAGE 1 memory map. It is also far easier to get a little used to thinking like a computer. Prob- remember that the cassette output port can be ably the best exercise possible for you would be to toggled by a reference to any address in the range write some 6502 assembly language programs. i5C02X ($('020— $('02P') than the range 49184— You'll sink or swim in hexadecimal and binary 49199. Dear reader, the effort you spend learning number systems. your binary and hex systems will be well worth it. v,i.^ appendix G Revisional Information The Apple lie computer was released in 1983 of the C,^> LSIO NAND ^ate so that pullin^r pin f,r^ with its 820-0064-A (Revision A) motherboard. of the auxiliary slot low forces TP^XT processing This event had been weil anticipated, but there at the timing HAL instead of disabling mother- was a little surprise for new purchasers of the board ROM as it did in Revision A (.see P'igures 8.9 Apple lie and 64K RAM card. The RAM card and 6.1). The nomenclature of pin 55 was appro- manual described 560-point HIRES graphics that priately changed from KNFIRM to FRCTXT'. were only available on a Revision B motherboard Changes in the timing HAL and MMU were with a 64 RAM card installed in the auxiliary slot. required to make the new FRCTXT' wiring work. ^vision B? Improved capabilities? Available soon? The Revision B timing HAL treats pin 12 as Why do they do these things to me? Why do they GR+2' wherea.s the Revision A timing HAL treats do these things to themselves? pin 12 as C.R+2. The MMU was changed so that Revision B was released a few months later, ROMENl'and R0MEN2' are gated by INHIBIT', ^™^»I1 the Revision A inventory had been clear- a necessity since the ROM inhibiting function had ed. Relatively few Revision A Apple He's were been performed by the NAND gate which now sold and most of those that were sold were traded performs the forced text function. It is my understanding that the video timing tI *=°"^^'no'*^^d *^o Revision B Apple He's, V,*'" been inere has relationships were different in the Revision A tim- operational change to the moth- erboard since Revision B, so Revision B effectively ing HAL from what they are in Revision B. 1 have 's the Apple He. never examined the .signal outputs of a Revision A The primary operational improvement of Revi- HAL, so I'm not positive what the differences are. sion BIS the addition of the DOUBLE-RES graph- I have noticed that the VID7M/LDPS' relation- ics capability. This was achieved by rewiring 1/3 ship depicted on page 159 of the Apple II Rafi-rem-e G-2 Understanding the Apple lie on the PAL motherboard. The PAL motherboan Manual for lie Only is incorrect for the Revision B contains two language sets in the keyboard ROfc HAL, and I speculate that it may show the Revi- and in the video ROM, and a mechanical switcl sion A timing. In any case, wiring and component connected to J19 will switch between video anc changes were made to the video summing ampli- keyboard sets simultaneously via the ALTCHF fier in Revision B, and these would be necessary to realign COLOR REFERENCE to the PICTURE line. signal if video timing in the HAL were changed. The keyboard ROM on the NTSC motherboard Another area of change in Revision B was in the contains two character sets, but the video ROM functions of motherboard configuration jumper contains only one. In Revisions A and B, the nor- pads. Two new jumpers were added (X3 and X7), mal configuration is for only the standard key- and the functions of XI and X2 were changed. The board set to be enabled. This configuration can be functions of all Revision A and B jumper pads as changed via XI and X2. well as the functions of the jumper pads on the In NTSC Revision A, X2 is normally open, and PAL motherboard are given below. the keyboard ROM alternate set selection line is The revisional history of the PAL motherboard normally connected to ground through XL By is very similar to that of the NTSC motherboard. opening XI and closing X2, the owner can remove Its Revision A version was released (with no the ground and connect AN2 to the keyboard DOUBLE-RES graphics) at the same time as the ROM alternate set selection line. This enables Revision A NTSC motherboard. The Revision B programmable switching of keyboard sets via version with DOUBLE-RES graphics was released AN2. To connect a mechanical switch, leave X2 soon afterwards, and Revision B is still current. open and open XI. J19 does not exist in NTSC An additional change that was incorporated in Revision A, but the select wire from the switch Revision B to the PAL motherboard was the inclu- can be soldered to XI or X2 or to pin 19 of a sion of the color killing switch in the production separate socket installed between the keyboard motherboard. This late addition did not get into ROM and its motherboard socket. the Revision A production board, but it was added In NTSC Revision B, the keyboard ROM alter- to the Revision A boards in a separate production nate set selection line is connected through the step. normally closed X2thejumper line and through pad open normally to theXI ENVID' jumper In summary, the characteristics that truly rep- resent the Apple He are those of the NTSC and pad to ground. In this configuration, the alternate PAL Revision B motherboards, and the primary keyboard set is selected any time the video ROM is change of Revision E was the addition of DOU- disabled via ENVID' high. To leave the standard BLE-RES graphics modes. Differences between set selected when ENVID' is high, open XI and the NTSC and PAL motherboards were noted in close X2. To select the alternate set via a mechani- Chapters 3 and 8. Essentially, the PAL mother- cal switch without disabling the video ROM, open board isidentical to the NTSC motherboard with X2 and leave XI open. As with Revision A, the the exceptions of PAL video generation, alternate switch can be soldered to XI or X2 or to pin 19 of a language character set selection, 14M frequency, separate socket installed between the keyboard and lOU vertical scan rate. ROM and its motherboard socket. APPLE lie JUMPER PAD FUNCTIONS X3-AN2 Control of ENVID' (NTSC Rev B. Figure 8.5) Most Apple lie owners never need to solder or In all versions of the Apple lie, pulling the break any of the motherboard or keyboard config- ENVID' line high disables the motherboard video uration jumper pads. On the other hand, readers ROM. One would only expect this to be done in of this book are just the type of people who would conjunction with an auxiliary card that substi- go in there and reconfigure the computer. Des- criptions ofthe jumper pad functions follow here. tuted an alternate picture signal on the ALTVID' line. An auxiliary card can pull ENVID' high Xi , X2- Character Set Switctiing itself, but there are two other options in the Revi- sion B NTSC Apple He. The owner can install a (NTSC Revs A and B, Figures 7,4, 8.5, 8.6) jack and switch at J19 to give mechanical switch Strictly for the purpose of character set switch- control over ENVID', or the owner can solder the ing, there really is no reason why there should be any jumper pads in this area, and there are none X3 jumper so that programs can control ENVID' via AN2. As noted above, the X2 jumper should be Ui'^ Revisional Information G-3 opened if it is desired that ENVID' be brought mod is built into the Apple He through the X6 high without selecting the alternate keyboard set. jumper pad. Just solder X6, and you will connect SHFT' to PB2, effectively installing the SHIFT X4,X5-Performing DMA Without Stopping key mod. ItieMPU Clock The SHIFT key mod is not a necessity on the (All Apple He's, Figure 4.2) Apple He unless you want to run an old Apple II With X4 and X5 normally configured, the program that works only with the SHIFT key mod PHASE 0 clock of the 6502 is prevented from ris- and does not interpret direct upper and lower case ASCII from the keyboard. It is also advisable to ing when the DMA' line is held low by a peri- solder X6 if you have no device connected that pheral card. PHASE 0 continues to alternate throughout the rest of the motherboard and peri- makes use of PB2 so you will have a convenient pheral slots, but it stays low at the MPU. This is means of exercising PB2 if a program requires it. fine for DMA peripheral cards which only need to steal a cycle or two of bus access from the 6502, X7-GR+2 Connection to Slot 7, Pin 23 (NTSC Rev B, PAL Rev B, Figure 7.6) but it means that peripherals which steal upwards often cycles in a row may cause the 6502 data reg- Pin 23 of Slot 7 was not connected to anything in isters tolose their values. Revision A. In NTSC and PAL Revision B moth- The owner can change this situation by opening erboards, its connected to GR+2 from pin 2 of the X5 and closing X4. PHASE 0 will then continue to lOU through normally open jumper pad X7. The alternate at the 6502. even when DMA' is low. installation instructions of Slot 7 peripheral cards Care, however, must be taken by peripheral card that require GRAPHICS/TEXT lime identifica- designers wishing to use this feature because the tion will tell you to solder XT. 6502 will attempt to execute programs while not controlling the bus during DMA unless it is put Keyboard COh4TROL Required for into a wait state by pulling the READY line low. Reset Jumpers Tb perform long duration continuous DMA. pull (All Apple lie. Figure 7.4) READY low in conjunction with DMA'. To force You must normally press CONTROL and RK- feed the 6502 a program by addressing one area of SET simultaneously to reset the Apjile He. This is memory while the 6502 is addressing another, pull a design precaution that [irevonts accidental resets DMA' low but leave READY high. by mutinous or otherwise uncontrollable fingers. The precaution is not really necessary since the X6-Shift Key IVIod RESET key is recessed and separated from the (AltApple He, Figure 7.2) rest of the keys (solitary confinement for crimes The SHIFT key mod is an improvised way of committed in the late 1970s), and it is inoperable inputting upper and lower case characters on the for many handicapped persons. To change this so upper case only Apple II. It consists of connecting the RESET key generates a reset without the a wire jumper between the SHFT' line and the necessity of pressing CONTROL, remove the key- PB2 game I/O input. PB2 then reacts to the board to gain access to its two unmarked jumper SHIFT key, and text handling programs can read pads. Close the normally open pad and open the the keyboard ASCII and interpret it as upper or normally closed pad to make C'ONTROL not re- lower case depending on PB2. The SHIFT key quired for reset. appendix H Historical Notes The original Apple was designed in late 1975 by code, early other as were the system programs for themonitor Apple. and Wozniak's Steve Wozniak, a talented college dropout who designed computers for fun. At some point in time, In fall of 1976, Wozniak completed the design of Wozniak entered into a partnership with his friend the Apple II. This new computer far surpassed its Steve Jobs, named the machine after a fruit, and predecessor in sophistication with HIRES and sold a few hundred of these Apples. This original LORES graphics capability. 48K of RAM, BASIC Apple had a 6502 microprocessor, 8K of RAM, no and system monitor in ROM, built-in cassette I/Or motherboard ROM beyond the screen text ROM, a and eight peripheral expansion slots with mother- motherboard power supply, and a single slot into board decoded slot control signals. The Apple II, which a cassette interface board plugged. The no doubt, borrowed many features of hardware Apple was sold only as a circuit card, but enclo- and program structure from the 1976 Apple, but sures and keyboards were available. most people would not recognize the older com- Of central importance to the first Apple was the puter as an Apple. 6502 microprocessor, which was then brand new. While developing his Apple designs, Wozniak The 6502 was simple, powerful, and available for was not a lone talent working in solitude at his $20.00 over the counter to all comers. This acces- cerebral pastime. He was a member of the Home- sibility made it an inviting MPU for an independ- brew Computer Club, the club to end all clubs, ent designer like Wozniak. Steve was a pioneer in from whose membership rolls have come several building hardware around the 6502 and in pro- microcomputer industry leaders. His friends were gramming the 6502. His BASIC interpreter was probably the first BASIC written for the 6502. very interested in Steve's Apple and made sub- stantial contributions to the Apple. Steve gives This program was written directly in machine Allen Baum much of the credit for the peripheral Historical Notes H-2 slot structure. In his "Apple II: System Descrip- duet, and I know nothing of its architecture or tion,"* he mentions Baum for originat capabilities. Apple II debug software, Doug Kraul foring- the helpful At some point after Annie was shelved, Apple suggestions on I/O structure, and Randy Wigging- engineer Burrell Smith began work on a different ton and Chris Espinosa for testing Apple BASIC. improved Apple II. Smith built an Apple II (code The contributions of Steve Jobs to the Apple II name Diana) in which many logic functions were were of a different nature. Jobs was not very performed by PALs. Like Annie, Diana never interested in designing computers, but he was made it to production. Its development was side- very interested in selling the Apple. It was Jobs who thought big, who thought the Apple could be tracked by Smith's assignment to the Macintosh project and by the fact that a custom IC approach sold, and who pushed Wozniak in his development to an improved Apple 11 seemed more promising. of a computer which was getting better and bet- However, some of Diana's architecture, including ter, It was Jobs who talked big to people who the timing HAL and video ROM, was borrowed by counted: to Rod Holt who came over from Atari to the Apple He. In my opinion, the video ROM is the help with electronic engineering tasks such as cleanest improvement in the design of the Apple power supply design; to suppliers who were giving He over that of the Apple II. I'm not sure who them components at discount prices with 30 days originally came up with the idea, but it may have credit; to Mike Markkula who gave the new com- been Smith or longtime Apple engineer Wendel pany business leadership and a quarter of a mil- Sander. lion greenbacks in seed money. The engineer in charge of project Annie at Syn- The Apple computer company officially came ertek was Walt Broedner. Walt left Synertek in into existence in January of 1977. Company lead- 1981 and went to work for Apple, first on the ers included Markkula, Jobs, Wozniak, Holt, and Apple III, and later on the Apple II. At Apple Mike Scott who came over from National Semi- Broedner continued to support the concept of conductor tobe company president. Wozniak has a using custom ICs as the basis for improving the recollection of Scott answering phone calls to Apple II design. To bring his point home, he de- Apple while dubbing cassette tapes on a string of signed the the MMU and the lOU, reworked the tape recorders. The company shipped its first Diana video timing to make it support DOUBLE- Apple II in June of 1977 and had paid off all its RES graphics, and built a working prototype of debts by December of the same year. Growth of the Apple lie. In doing this. Broedner also de- Apple II sales never stopped increasing as long as signed the Apple lie. because his prototype oper- it was manufactured. ated like an Apple lie if you threw some switches. While the original Apple II was produced by a It is certain that others besides Walt Broedner* small group of talented and lucky individuals, had a hand in Apple lie development. Engineer- more recent Apple products, including the Apple ing manager Peter Quinn oversaw the entire pro- He, were produced by corporate Apple. Ideas for ject. Gary Baker incorporated his Eurocolor card future products ebb and flow in a corporate entity into the PAL motherboard and designed the video for years, and so it was with the concept of an amplifiers of the NTSC and PAL motherboards. improved Apple II, more powerful, but cheaper to The new Apple lie firmware was written by Rick manufacture. Steve Wozniak was the force behind Auricehio. As was mentioned previously, Burrell the original idea. He worked with Synertek on an Smith's Diana work was significant. Wozniak. of early project (Apple code name Annie, circa 1978) course, was most influential since it was his com- that used custom ICs to perform many Apple func- puter that was being redesigned. tions. Annie was never developed into a final pro- *After desijrninjT the Apple He and lie, Walt Broedner left 'BYTE Magazine, May 1977 Apple to form a new company. Video-7 !nc. appendix I Apple ll/lle Difference Notes Most Apple users are aware of the primary two computers pointed out under Chapters 2—10 operational differences between the Apple II and below. the Apple lie, and in fact, these differences have The difference in hardware implementation be- been well described in various writings. However, tween the Apple II and the Apple He are greater the magnification power of Understanding the than the operational differences. Basically, the Apple lie is turned up a little hig-her than most Apple II motherboard was rebuilt from the ground Apple lie writings, and examination at this level up using custom ICs, the timing HAL, bigger turns up differences too obscure to be noted in RAM and ROM chips, and redesigned logic struc- more general descriptions. So, for those who like tures to achieve and improve upon old features in the view of the trees from inside the forest, here simpler ways, In addition to motherboard hard- are some notes on differences between the Apple ware changes, a few changes were made to the 11 and lie. These differences are listed under the case and base plate structures including a rede- chapter in which their related area is covered so sign of the back structure so that it is less conve- the reader may know where to look for further nient to string peripheral slot cables out the back, explanations. but so that the outside world is better protected from Apple RFI emission. Chapter 1— Overview As noted in Chapter 1. the Apple lie is opera- Chapter 2- Bus Structure tionally compatible with a 48K Apple II with 16K Distribution of the address bus and data bus in RAM card in Slot 0, 80-column card in Slot 3, and the Apple II and Apple He is, of course, similar. an enhanced keyboard. The major improvements This is dictated by the nearly identical MPU, beyond this consist of motherboard support for peripheral slot pin assignments, and operational 64K of auxiliary RAM (an auxiliary 48K plus an features of the two machines. There are, however, auxiliary Slot 0 RAM card) and the DOUBLE- numerous differences in the bus distribution de- RES graphics modes. Additionally, there are nu- tails, most notably in the RAM area. The main merous minor operational differences between the reason for these differences is that packing the (•,'dtiiEi Apple ll/lle Difference Notes 1-2 logic functions of many small ICs into the two to drive the data bus during write cycles, even large custom ICs required things to be done in with all the motherboard and peripheral card new and different ways. Also, the larger RAM and devices connected to the data bus. In the Apple ROM chips and auxiliary slot of the Apple He He, the bidirectional driver is situated be- result in some differences. tween the peripheral slots and the data bus. 1. RAM Address Multiplexing— In the Apple The MPU must therefore drive the heavy II, the address bus and video scanner provide motherboard data bus load during write cy- inputs to a 4 to I multiplexor which outputs cles without the aid of a driver. This load is VIDROW, VIDCOL, MPUROW. and MPU- constant and does not vary with peripheral COL addresses in turn to RAM on seven lines. card installation. An advantage of the Apple The 4 to 1 multiplexor does not have tri-state He implementation is that motherboard devi- outputs, so the multiplexed RAM address bus ces like RAM and ROM have more driving never floats. In the Apple He, the MMU and power when supplying data to the peripheral cards during DMA read cycles. Also, the lOU drive the 8-line RAM address bus with Apple He design tolerates more peripheral tri-state outputs. While the MMU presents a card data bus loading than that of the Api^ile high impedance, the lOU places the VIDROW II. then VIDCOL addresses on the RAM address bus. While the lOU presents a high imped- ance, the MMU places the MPUROW then Chapter 3— Timing Generation and MPUCOL addresses on the RAM address bus. the Video Scanner The MPUROW address is input to the lOU as The primary timing signals of the Ap|)le 11 and well as to RAM. The RAM address bus is dis- the Apple IIe-14M, 7M, COLOR RKFP:RE-;N('L, tributed toauxiliary card RAM in addition to RAS', AX, CAS', Q8, PHASE 0. and PHASK 1- motherboard RAM, and there is a short period are nearly identical. The fretiuencies. seriuences. of time just before the VIDROW and MPU- and the long cycle are the same in the two com [ni- ROW addresses when the RAM address bus ters. The video scanner is also functionally identi- floats. cal in the Apple II and He with i"i cycles ])vr 2. RAM Output Data Distribution— In the Ap- horizontal scan, 2fi2 horizontal scans per \-ertical scan in the 60 Hz Apple, and IU2 horizontal scans ple II, RAM output data is latched and dis- tributed to the RAM/keyboard data multi- per vertical scan in the 50 Hz Apple. Some notable differences: plexor and to the video generator. The RAM/ keyboard data multiplexor places either the latched keyboard data or the latched video 1. CAS' is gated by CASKN" from the MMUdtir- data on the data bus when a read is made in ing PHASE 0 in the Apple He. This is the \\'ay motherboard RAM is enabled or disabled, in the $0000— $CO0F range. In the Apple He, the Apple II, CAS' always falls after AX falls, motherboard RAM output data goes directly and CAS' from the timing generator is gated to the data bus for reading by the MPU and to one of three octets of HAM chips during saving in the motherboard video latch. Auxil- PHASE 0 by $00OO-$;^FFF, $.10()()--i?7FFF. iary RAM data input and output lines are or $8000-$BFFF addressing. connected to the auxiliary video latch and to a bidirectional driver. The bidirectional driver 2. CAS' in the Apple II rises simultaneously with passes data between auxiliary RAM and the RAS'. RAS' rising latches RAM read data, data bus when the MPU is reading from or and CAS' rising causes the RAM chips to bring their data outputs to high impedance writing to auxiliary RAM. The auxiliary video after a short delay. In the Apple He, RAM latch saves video data from auxiliary RAM and gates the video data to the video data bus read data is not latched by RAS' rising so at the correct time for processing in the video CAS' rising had to be moved back closer to the generator. The keyboard circuits in the Apple end of the 6502 cycle. CAS' rises one 14M He have their own tri-state connection to the period PHASE after RAS' rises 0 or PHASE (simultaneousl.v with 1 rising). data bus. 3. In the Apple II, the long cycle occurs at a hori- 3. The Bidirectional Bus Driver— In the Apple zontal scan count of 0000000. In the Apple He, II, there is a bidirectional driver between the the long cycle occurs 1 ';. scan counts later. MPU and the data bus. This enables the MPU straddling horizontal states 1000000 and 1-3 Understanding the Apple He 6502 PHASE 1. The Apple He 6502 is con- 1000001. The reason for the difference is that nected directly to the data bus. 6502 PHASE 1 there is a greater lag between RAM address- in the Apple He is not connected. ing and video output in the Apple He timing 3. The 6502 SYNC signal is connected to pin 39 generator. In the He. the long cycle had to be of the peripheral slots in the Apple lie. 6502 pushed back so it would not interfere with the SYNC is not connected in the Apple H. last video output cycle of each horizontal scan. 4. The 6502 SET OVERFLOW input is ground- 4. An Apple He auxiliary card can monitor the ed in the Apple II, but it is open in the Apple timing signals and substitute its own signals lie. for the motherboard timing signals. There is 5. Wire-OR control inputs from the peripheral no similar capability in the Apple H. slots are pulled up with 1000 ohm resistors in 5. The flash counter, which is an extension of the the Apple II and 3300 ohm resistors in the video scanner, does not exist in the Apple H. Apple He. This results in slower low to high The Apple II uses analog timers to produce switching speed in the Apple He which can be time references for flashing text, the keyboard offset, when necessary, with parallel pull-up repeat function, and the power-up reset. resistors on peripheral cards. 6. The video timing signals, LDPS' and LD194 in 6. The X4 and X5 jumpers of the Apple He allow the Apple II and LDPS' and VID7M in the peripheral slot DMA operations which do not Apple lie, are entirely different. These differ- stop the PHASE 0 clock to the 6502. In an ences are due to the differences in the video generator hardware and the 80-column dis- unmodified Apple II, pulling DMA' low al- ways inhibits the 6502 PHASE 0 clock. play capability of the Apple He. 7. The hardware implementation of the timing 7. In the Apple lie, CAS' is pre-gated (CASEN' generator and video scanner in the Apple He gating occurs prior to 14M clocking), and is different from that of the Apple II, but the CAS' is applied directly to the RAM chips. In difference is mainly in the use of state-of-the- the Apple II, CAS' is post-gated (RAM SE- art ICs to achieve the same functions. (There LECT' gating occurs after 14M clocking) be- fore application to the RAM chips. As a result, is still an underlying similarity in the hard- in relation to PHASE 0 and 6502 PHASE 2, ware.) In both machines, the timing generator is made up of a 14.31818 or 14.25045 MHz CAS' in the Apple He falls typically 21 nano- oscillator whose output is divided and process- seconds (32 nsec max) before CAS' falls at the ed to make up the same timing signals. Also in Apple II RAM chips. 6502 write data must, both machines, the video scanner is a 262/65 therefore, be set up earlier in the Apple lie or 312/65 state counter whose outputs address than in the Apple II. This is one good reason display memory and trigger events related to for the use of a 2 MHz 6502A (100 nsec write television scanning. data setup) instead of a 1 MHz 6502 (175 nsec write data setup) in the Apple He. 8. Because of long address bus to multiplexed Chapter 4— The MPU RAM address bus propagation delay in the Both the Apple II and the Apple He use 6502 microprocessors, and most 6502 related infornia- MMU, DMA peripherals must set up the ad- dress bus earlier in the Apple He than in the tion in the two computers is identical. This in- cludes 6502 programming, speed of program exe- Apple H. 9. NMI', IRQ', and BREAK handlers in the Apple cution, interrupts, and the control signal connec- II with Autostart Monitor and the Apple lie are tions between the 6502 and the peripheral slots. However, there are numerous minor differences in identical. Reset operations are similar in most 6502 connections and related circuits. Some of aspects, including disk autostart, the power-up these differences are listed here. byte, and the RAM reset vector. The Apple He reset handler also supports open Apple and 1. The Apple II uses the 1 MHz 6502 while the solid Apple resets, and its video initialization Apple He uses the 2 MHz 6502A. The Apple routines support the improved Apple lie video He MPU is therefore tested to operate with features. shorter delays between events. 2. The Apple II 6502 is connected to the data bus 10. The Apple He can operate with a 65C02 micro- processor but an Apple II cannot. I think that through an external bidirectional bus driver this is because RAM read data in an Apple II is whose direction is controlled by R/W and set up too late for the 65C02. 1 have verified that Apple ll/lle Difference Notes 1-4 NCR 65C02S do not work reliably in the Apple scanned addresses in the Apple lie. II, but I have not verified this for Rockwell 6. Since HBL is not a RAM address input in the 65C02S. Apple He, SUM A4 and SUM A5 are ade- quate refresh signals and VC does not have to Chapter 5— RAM and be used for RAM refresh as it is in the Apple Memory Management II. As a result, the refresh period in the Apple He never exceeds 2 milliseconds. In the Apple No area of the Apple 11 and He computers is II, the refresh period slightly exceeds 2 mil- more different in hardware implementation than liseconds inHIRES mode during a portion of RAM and memory management. This is in spite of VBL. the fact that the Apple He is operationally similar 7. Motherboard RAM is connected to the data to a 48K Apple II with a 16K RAM card installed in Slot 0. Differences center around the use of 64K bus through buffering devices in the Apple H but is connected directly to the data bus in the RAM chips in the Apple He and the more versatile Apple He. This affects data bus management memory management features of the Apple He. in all MPU communication in that you don't 1. The Apple II has 48K of motherboard RAM in have the RAM/keyboard data multiplexor 24 16-kilobit chips. The Apple He has 64K of jumping on the Apple He data bus right after PHASE 1 goes high. motherboard RAM in eight 64-kilobit chips. 8. Details of MPU/RAM communication timing 2. The 16K RAM card is not affected by RESET' falling, is not inhibited by the INHIBIT' line, are different in the two comjuiters utMi genej-- does not support reading of the configuration ally less critical in the Ajiplo He. A notable exception is that the (>r)()2 ha.s about 21 nano- soft switches, and steals $F800— $P"FFF ad- dress response for its F8 ROM when its RAM seconds less time to set uji RAM write data in is disabled for reading. Apple lie high RAM is the Apple He than it does in the .Aitiilc 11 (see disabled for reading and enabled for writing Chapter 4. item 7 aijove). Also, liecause of long when RESET' fails and is inhibited when address bus to mvi!tii)lexe() R.AM address bus INHIBIT' is low. The state of the HRAM- propagation delay in the MMU, DMA periph- READ and BANKl soft switches can be read erals must set up the address bus earlier in the at$C012and$C011. Apple lie than in the Apple II. 3. Apple He memory management fully supports 9. The MMU and most of its cai)abilities do not access to 64K of auxiliary card RAM. There is exist in the Apple il. Of the M.Ml.^ softsu'itches, 80STORE, RAMRD. UAMWHT, INTCXROM, no equivalent capability in the Apple II. SLOTC;^R()M, INTC^ROM. and ALTZl' and 4. The RAM address multiplexor of the Apple II the memory management functions of l'A0E2 is a 4 to 1 multiplexor made up of a number of and HlRESdonot exist in the Apple 11. Addition- TTL chips driving seven 2-state RAM address ally, HRAMRI), PANKl. PRE-WRITK, and lines. The RAM address multiplexor of the HRAMWRT' exist only on a IGK RAM card in Apple lie is a 4 to 1 multiplexor made up of an Apple II. not on the molherboar0» Q3'» Keyboard: RAS". 3, The ALTCHRSET, 80STORE. and 80COL soft 1, Early Apple II keyboards cannot input ASCH switches do not exist in the Apple II. The Apple for lower case alphabetic and some control II only has modes equivalent to ALTCHRSET'* characters. Later Apple II keyboards can 80STORE' • 80COL'. input lower case alphabetic characters if the Apple ll/lle Difference Notes 1-6 user installs a switch, but the lower case key- 5 The INHIBIT' line of the Apple II inhibi ts board input is not supported by Apple 11 firm- motherboar d ROM but does not affect RAM. ware. The Apple He keyboard can input all The INHIBIT' line of the Apple He inhibits 128 ASCII codes and there is some degree of rboard and auxiliary card memory (RAM motheROM). and firmware support for lower case keyboard input. are 6 Pins 19 of Slots 0—6 and pins 35 of Slots 0— b any 2 There are a number of keys on the Apple lie connected together but not conne cted to ' keyboard that are not on the Apple II key- signal in the Apple II. Pins 19 and 35 of Slots board including DELETE. TAB, CAPS LOCK, 2—6 in the Apple He are not connected. open and close Apple, up and down arrow, and 7 Peripheral slot wire-OR lines are pulled up by several special character keys. IK motherboard resistors in the Apple II and 3 The layout of Apple II special character keys by 3.3K motherboard resistors in the Apple ' is similar to that of a teletype. The simil layout of He. Apple He special character keys .is ar to riter Auxiliary Slot: that of an IBM Seled ric typew key- 4 The Apple He keyboard ROM with dual I The auxiliary slot and the capabilities asso- ' board layout enables the user to switc h be- ciated with it exist only in the Apple He, not tween keyboard layouts or reprogram the two in the Apple II. layouts. There is no similar capability m the Apple II. -If Chapter 8— Video Generation erbo ard conta ins a jack lor Apple 5 The Apple He moth Apple He video output is compatible with bYNO, ' a numeric keypad. The Apple 11 moth erbo ard II video output to a very great extont. does not have such a jack although later Apple COLOR BURST, and blanking logic equat ions in H akeybo ards have holes meant for installation the Apple He are identical to those of the later of keypad jack. ,^ti c n ES Appl e Soil Apple II (RFI Revision), and SINGLE-R 6 See also items 4, 6, and 7 under lOU Apple II displ ays pro- Switches and item 2 under Seria l I/O above . He displays are identicalryto map (exept as noted in duced bythe same memo gem video Peripheral Slotsi item 7 below). The big operational ^han addit ion of the DOU BLE -RES (1-7) in generation isthethemost striking change to a student 1 There are only seven peripheral slots modes. But to eight penp heral ware is the cleanup of the video the Apple lie compared Slot 0 of Apple II hard slots (0-7) in the Apple II. The Apple H generator design. , $C08 X, is used to The differences: DEVICE SELECT' range configure high memo ry in the Appl e He. lay modes 2. The bidirectional data bus driver in the Apple 1 The double horizontal resolution d'sp ES and II is situa ted betwe en the MPU and other data (80-character TEXT. 80-block LOR not exist Appl e He do bus devices. The bidirectional data bus drive r 560-point HIRES) of the speed tim- en the peri- in the Apple H. Neither do the high in the Apple He is situated betwe ing and auxi liar y memo ry whic h are required pheral slots andbusseria l input multiplexor and le resol ution mod es. _ the other data devices. to support the doub y is on circ uitr can dis- 2 The design of the video generatithan it is m the 3. An Apple He Slot 1 peripheral card oard cir- much cleaner in the Appl e He able motherboard timing or the keyb Anple H. In addition to integrat ing many cuits via CLKEN' and ENKBD' respectively. the lOU, the teg These lines do not exist in the Apple II. video logic functions into ster , HIRES/ natt ern ROM , text shif t regi 4. Pin 39 is connected to the USERl line in the LORES configurable graphics shift register, the Apple H and the 6502 SYNC signal in ii selection themultiplexor, and synchroniz- Apple He. Any peripheral card m the Apple picture flip-f ing lop in Appl e II are replaced by can disable all $CXXX I/O decoding bym pul- one shif t regi ster in the the Z video ROM and ling USERl low. A similar capability am can disabl e d text characters and grapac-h- Apple He is that any progr ulati ng ■^ aSdIc He displaye by rep $C100— $CFF F I/O decod ing by manip '■ fcs cha acter' istL can be chang ed , INTCXROM, SL0TC3R0M, and INTC8R0M text characters canno t be disab led in the ng the video ROM. Displayed text ROM in $COXX I/O decoding by repl acin can be changed later Apple Hs. g the Apple He. 7 and Revision 1-7 Understanding the Apple lie 11. HIRES40 colors can be instantly switched ard Apple II mothe rboar d can be con^ between delayed and undelayed colors via 4 A stand the 5U figured for PAL video output by making FRCTXT' in the Apple He. There is no equi- crysta on Hz jumpers, installing a 14.25 MHz valent capability in the Apple H. the motherboarard d, and instal ling a "Eurocolor 12 The abnormal LORES mode resulting from PALencodinKc in Slot 7. With the Apple lie, are resetting 80COL and bring inFRCTXT' low in different NTSC and PAL motherboards the Apple lie does not occur the Apple II. m of the used depending on the television syste 13, Video generation timing in the Apple 11 and country they are operated in. cters. He have similarities but are very different in 5 The Apple He can display 96 text chara detail. Apple lie timing is delayed by video The Apple II can displaybe only 64 text charac- ters although this can increased to 96 by ROM access time, and DOUBLE-RES timing exists only in the Apple He. changing the text ROM of Revision 7 and later Apple lis. 6 The Apple lie can switch between Apple 11 Chapter 9— The Disk Controller compatible inverse and flashi ng video and full There is no difference in floppy disk I/O be- ASCII inverse via the ALTCHRSET soft switch . tween the Apple II and Apple lie. The controller. disk drive, and operating systems are not built The Apple II can operate only in ALTCHR- and therefore evolve separately SET' mode. into the Apple 7. In Apple II HIRES 40 mode, delaye d patter ns from the compute r. Advances made since the re- at the far left extend undisplayed dots onto the lease of the Apple He include the development of screen, and delayed patterns at the far right several Disk II compatible drives, the introduction can be cut off by following undis playe d pat- of ProDOS, and the development of the IWM (In- terns. In Apple He HIRES40 mode, delayed tegrated Woz Machine) which is a custom IC that patterns at the far left extend the left hand emulates the Disk II controller and may be used in blanking margin, and delayed patterns at the future Apple Il/IIe controllers. far right are always cut off. 8. The Apple He capabilities of monitoring and Chapter 10— Maintenance and Care disabling video signals and injecting an alter- Much that can be said about maintenance and ry card do the nate picture signal from an auxilia care of Apple computers is valid for either not exist in the Apple II. peri- Apple II or the Apple He. In the the Apple He, 9. Low-high propagation delay is significantly pheral slots, tinker ing users, and power supply shorter than high-low propagation delay on as reliab ility weak links, and basic prob- remain the PICTURE signal of the Apple II. This lem troubleshooting steps like remov ing periph- causes bright spots to be about 24 nanoseconds eral cards and evaluating the video display are the wider than equivalent dark spots. No such same. Some things have changed, to be sure and effect is noticeable in the Apple He. ly the Apple generally, for the better. Most notab 10 At the signal sources, the PICTURE signal He is more reliable, aser.has been amply verified by (referenced to COLOR REFERENCE) of the this world class tinker of the Apple He by one 14M de Apple II lags that Apple lie reliability improvements inclu period. COLOR REFERENCE is delayed more stronger motherboard mount ing near the periph - in analog shaping circuits in the Apple II than eral slots and a reduced number of motherboard the Apple lie, so at the video summing ampli- ICs. Additionally, the verification and fault isola- fier, the PICTURE signal/COLOR REFER- tion capabilities repre sented by the firmware diag- ENCE relationship is identical in the two com- nostics and the auxiliary slot are not present in the puters. Apple II. index Aalto, Jim 9-34 Apple Orclmni 8-,37, 8-45 Accumulator 4-9 to 4-10, 4-17 Applesoft Basic 1-3, 4-U, 4-25. 6-7. 6-9. 8-44, gl-! address bus 1-2. 2-1 to 2-20, gl-1 Appli'K-rili-r 7-,37 and add ress decod ing 2- 10 to 2- i 6, 7- 1 to 7-2 Application Notes (see Hardware Applications: Software and DMA 2-17 to 2-18, 4-5, 4-11 to 4-12 Applications) and MPU 2-6, 4-2 to 4-5. 4-6 to 4-S ASCII l-8.Ki-l and peripheral slots 2-16 to 2-17, 7-15, 7-18 screen 1-8, 8-8, 8-13, 8-15, 8-25, 8-40 and RAM address multipiexinE 2-7, 5-2 to 5-9 keyboard 1-9, 7 10 to 7-17 and ROM 2-6.6-2.6-3 assembly language 4-10 to4-ll, gl-1 andserialI/0 2-18,7-5.7-6 and 6502/65C02 instructions 4-23 to 4-28 Atari, Inc. 4-1, H-2 audio (see Speaker) address decoding 2-10 to 2-16, 7-1 to 7-4 Auriechio, Rick H-2 and R/W 7-2 and 6502 1-2 to 1-3, 4-5 Autostart Monitor 6-7. 6-8. 6-10 lOU 2-12,7-2 and Apple li Plus 6-7 list of functions 2-13 to 2-14 and disk boot 4-15,912 MMU 2-10 to 2-12. 5-30 and RESET' 4- (5,6-11 (also see monitor) peripheral address deeodinir 2-12, 7-1 to 7-4 address fields. DOS 9-2, 9-4, 9-26 to 9-28. 9-39 to 9-42 lalso see AUTOSTRB signal 3-14, ,3-17, 7-4. 7-15 DOS data formats) auxiliary siot 1-4 to l-,5. 2-17. 7-26 to 7-28 AKD (Any Key Down) 2-16, 6-11, 7-3, 7-4, 7-12, 7-15 and bus structure 2-7 to 2-10 ALTCHRsignal 7-14,8-19.0-2 as diagnostic port 3-19, 7-27. 7-28. 10-5 connections 3-18 to 3-20. 7-26 to 7-28 ALTCHRSET soft switch 7-4. 8-8 to 8-15. 8-20, 8-21 RAM 5-1 to 5-,5. 5-24 to 5-27. 5-35 to 5-38 ALTV]D' signal 7-26, 7-27. 8-10, 8-11, 8-18 reliability 10-2 ALTZP soft switeh 5-22, 5-25 to 5-27. 5-30 to 5-33 IK RAM card 5-.38 to 5-39 switching convention 4-19 64K RAM card 1-3, 2-7 to 2-10. 5-1 to 5-5. 5-35 to 5-;i8, 7-2K ALO— AL5, AL7 2-7. 5-6, 7-3. 7-4 {ses also MMU; RAM; {>eripheral .^lots) AMI (American Microsystems) 1-6. 3-7 AX signal 3-5 to 3-6. 3-20 to 3-22 AND gate E-1 to E-3. gl-I ANIMATRIX 8-41 Baker. Gary 8-17, H-2 annunciator 1 -1 1 , 2- ! 8, 7-2 to 7-6. 7-27 bandwidth 8-7, 8-47 to 8-48. gl-1 AN2 and alternate characters 7-11. 7-13. 7-37. 8-10. 8-1 1. G-2 bank switching 5-20 to 5-28. gl-l AN3 and FRCTXT' 3-18, 5-4, 8-20 to B-24 Apple Computer, Inc. 1-1. 1-5.3-17,3-20,4-1,4-15,4-18.4-20,5- DOS BOSS 6-12 to 6-18 24, 5-28. 5-32, 6-2, 6-6 to 6-9, 6-11. 7-14, 7-19. 7-20, 7-21. 7-24. 7- (alsosee MMU; INHIBIT') BASIC 4-10 to 4-1 1, 6-6 to 6-7, gl-l. li-1 28, 7-37. 8-16, 8-17, 8-18, 8-31. 9-1 to 9-2. 9-4. 9-9, 9-14, 9-16, 9-34, 9-40. 9-43 to 9-45. 10-3, 10-5. 10-6, B-l.H-2 and disk I/O 9-34 Apple II computer and paddle programming 7-29 to 7-30 and65C02MPU 4-22 and Page 0/Page 1 4-5 and 6502 instruction details 4-25 Apple lie compatib ili ty 1-1 , 5-40, 5-42, 7-2, 7- 19, 8-24, 8-26. 8- in ROM 1-3. 2-6. 6-6 to 6-7 34, 1-ltoI-7 design of 4-12, 5-7 to 5-8, 5-12. 5-20, 8-3 programming 4-10 to 4-11 (also see Applesoft BASIC; Integer BASIC) Eurapple jumpers 8-17. 1-7 firmware 6-6 to G-8 BASIC Froftriimmlut, With PninOS 9-34 history H-1 to H-2 Batim. Alan H-1 to H-2 memory/display scanning 5-13, 8-16, 8-17, 1-4 Baum. Petor 4-6 normal/inverse/flashing text 8-8, 8-13 Bth Appk- DOS 9-1. 9-34 paddles 7-7,7-34 Bemtilh Appli- PmDOS 9-1. 9-34 SHIFT key mod 7-6. 7-7, 7-35, G-3 bidirectional bus drivers USERliine 7-19. 1-6 auxiliary card 2-9. 5-3 to 5-6, 5-35 to 5-39 80-column card emulation 1-8, 5-28. 6-8, 7-23 peripheral data bus (see peripheral data bus) Apjsh UE.rien(led KO-CnIiimn Tc.,1 Curd Supplement for Hi' (also see MD IN/OUT'; peripheral slots) Onh/ 5-25 A.ppleIIPtus 6-7 binary information 1-2, F-1 to F-3 binary number system F-ltoF-3, gl-I Apple II Beferenee Manual 6-6 Bishop, Bob 5-40 Apple I! Referenee Manual far Ik Onhf 1-4, 3-28, 4-6, 4-7, 4-10, 5- bit 1-2, F-I, gl-l 7, B-IO, 5-25. 5-28. 6-8, 7-8, 7-10, 7-29, E-4, G-1 8-4 to 8-6, 8-11, 8-26. 8-37 to 8-39 (also see HBL; Apple lie 4-18 to 4-21. 9-2, H-2 VBL; 3-12, blanking WNDW) 2 Understanding the Apple He bomb (crash) 4-5, 4-17 to 4-18. gt-2 driver (see peripheral data bus driver) Boole. George E-4 lOU connection 2-16, 2-20, 7-4 Boolean algebra E-2 to E-4 keyboard connection 2-16, 7-11 management 2-2, 2-10 to 2-12, 5-21 to 5-33, 6-2 Bootstrap ROM 9-1. 9-9 to 9-12 management signals 2-12, 5-21, 5-24 to 5-33, 6-2 BREAK instruction 4-17 to 4-21 MMU connection 2-20. 5-30 software breakpoints 4'17. 4-18, 6-10 (also see timing diagrams; peripheral data bus) Broedtier. Walt 1-5, H-2 data fields, DOS 9-2, 9-27 to 9-28, 9-39 to 9-42 bus 2-1 to 2-20, ?l-2, I-l to 1-2 data register 9-10, 9-11, 9-14 to 9-15 drivers 2-1 to 2-3. 4-2 to 4-4. (rl-2 debounce 4-29 to 4-30. 7-10 to 7-12. gl-2 fijfhts 5-32, 6-4, 7-3, 7-24 to 7-26, 9-14 secondary buses 2-7 decimal number system e!-2, F-1 (also see address; auxiliary data; data; multiplexed RAM DEVICE SELECT 7-2, 7-4, 7-18 to 7-20, 7-24 to 7-26 address: peripheral data; video data bus; bidirectional bus digital computer gi-2, P-1 to F-3 drivers) Digital Research 4-11, B-1 byte I-2,frl-2 DIIDD (Disk II Device Driver) 9-4, 9-40, 9-42 to 9-45 BYTE FLAG 9-26, 9-29 to 9-32. kI-2 data formats 9-25 to 9-27 BrrA' Magazine 6-6. H-2 DIIDD/RWTS differences 9-42 to 9-45 head positioning 9-8, 9-13, 9-43 to 9-44 Caffrey. Morgan P- 4-17 disk controller 2-17, 9-10 to 9-34 CAPLOCK' siKnaJ 7-10 to 7-13 Bootstrap ROM 9-1,9-10 to 9-12 card casre 1-3 to 1-4, gl-2 (also see peripheral slots) command decoder 9- 1 1 to 9- 14 CAS' 3-4 to .3-1 1 , 3-20 to 3-22. 7-27, 1-2, 1-3 data register 9-14 to 9-15 R A M control 5-2 to 5-5, 5-32 to 5-37 drive ENABLE' 9-6,9-11.9-12 CASKN' 3-20 to 3-22, 5-3. 5-30 to 5-38, 7-24 to 7-25, 7-27 (also see drive off delay 9-13.9-36 ROM timing: 1/0 timing drive off/on 9-12 to 9-13. 9-36 to 9-38, 9-43 cassette I/O l-IO, 2-18, 7-3 to 7-9 drive select 9-12 and D MAnual Controller 4-32 head positioning commands 9-11 to 9-13 logic state sequencer (see logic state sequencer) read/ w ri te rou ti nes 6-10 character sets 8-13, 8-40 to 8-41 power-up reset 9-13 c hecksum S- 1 1 , 9-2(5, 9-4 1 , 10-7 read pulse processing 9-1 5, 9- 16, 9-29 to 9-35 chip (see integrated circuit) READ/WRITE 9-13, 9-14, 9-21 to 9-25 SH IFT/ LO AD 9-13 to 9-14, 9-2 1 to 9-24 chip select, ROM 6-2 WRITE PROTECT signal 9-7 to 9-8, 9-21 chrominance sisnal 8-5 to 8-6, 8-17 to 8-19, 8-47 to 8-48 WRITE RE(JUEST' 9-7, 9-8. 3-13 circuit symbols 2-2 to 2-3. El to E-5 WRITE signal 9-7, 9-23, 9-24 CLKEN' siRnal 3-18. 3-19. 7-18, 7-19 (also see disk topics; logic state sequencer; RWTS) clockpulse 1-2. 3-2 to 3-12. 4-2, E-2 disk drive 9-1 to 9-9 clockpulse jitter 1-2.3-28,9-25 (also see long cycle) analog card 9-2, 9-6, 9-16 close Apple key 1-10, 4-15, 7-7, 7-11, 10-6 apparent momentum 9-13 CLRGATE' 7-27, 8-10. 8-16, 8-18, 8-19 enabling 9-5,9-13 CMOS 4-21 erase head 9-6 to 9-8 cold start reset 4-15 motor speed up time 9-38, 9-43 coIlector-OR (see wire-OR) power supply 9-5, 9-36 read interface chip 9-8 to 9-9 COLOR BURST 3-15. 8-3 to8-7, 8-10. 8-16 to 8-19 read pick up signal 9-9 color fringes 8-28. 8-33 to 8-35 read pulse 9-8 to 9-9 color graphics 1-7 to 1-9, 8-7, 8-27 to 8-37 read/write head 9-5 to 9-8 COLOR REFERENCE 7-18. 7-27, 8-6 to 8-7, 8-17 reliability and repair 10-2, 10-5 generation of 3-4 to 3-10, 3-19 to 3-22 speed 9-2,9-43.9-45 color si j?nals 8-5 to 8-7, 8-lG to 8-19, 8-27 to 8-37, 8-47 to 8-48 stepper motor 9-2. 9-5 to 9-7, 9-13, 9-38 color subcarrier 8-17 to 8-19. 8-47 to 8-48 stepper motor response time 9-7. 9-38, 9-44 colors 1-8 to 1-9. 8-7, 8-27 to 8-37 write protect bypass switah 9-46 to 9-48 COLUMN address 2-7, 5-2 to 5-7 write protect switch 9-6 to 9-8 writing to disk 9-5,9-7 Commodore 4-1 (also see disk topics; logic state sequencer; RWTS) compilers 4-10 to 4-11, gl-2 disk I/O 1-10. 2-17, 9-1 to 9-48 complementary colors 8-32, gfl-2 booting 4-15, 7-22, 9-12, 9-38 composite video 8-3 to 8-7, gl-2 (also see video) bypassing write protection 9-46 to 9-48 CP/M (Control Program for Microprocessors) 4-11 controller (see disk controller) CSST OUT ai gnal 7-3 to 7-9 data formats (see DOS data formats) CSW (Character output SWitch) 7-21 to 7-23 datapaths DIIDD (see 9-1 to 9-5 DIIDD) CTRL' signal 7-10,7-11,7-13 DOS (see DOS) cursor 8-40 drive {see disk drive) cycle stealing 4-!lto4-14, 4-29, el-2 formatting 9-4, 9-39, 9-43, 9-45 CXXX signal 5-28 to 5-33, 7-2, 7-4, 7-24 to 7-25 hard sector 9-3 COXX' signal 7-2 to 7-4, 7-24 to 7-25 head positioning 9-5 to 9-7, 9-13. 9-38, 9-43 to 9-44 C04X'. C06X', C07X' signals 7-2 to 7-6, 7-24 to 7-27, 7-i programming 9-12 to 9-15, 9-21 to 9-26, 9-34 to 9-46 C040 STROBE' 1-11, 4-25,7-2 to 7-6 read process 9-4, 9-5, 9-39 to 9-45 RWTS (see RWTS) data bus (MD0-MD7. MOS data bus) 1-2. 2-1 to 2-20, gl-2 soft sector 9-2 and auxiliary slot 7-26 to 7-27 write interval 9-9, 9-15, 9-21 to 9-26 andMPU 2-2 to 2-6. 4-2 to 4-9, 4-11 write process 9-4 to 9-5, 9-39 to 9-46 and peripheral slots 2-16. 7-15, 7-18 write protection 9-6 to 9-8, 9-21 and ROM 6-2, 6-3. 6-5 to 6-6 (also see disk topics; logic state sequencer) and 6502 instructions 4-23 to 4-28 display, video (see video; screen; menwry) Index 3 D MAnual controller 4-2S to 4-32, 7-19 80-column 6-8,6-9,7-21,7-23.8-14 DMA (Direct Memory Access) !-4, 2-IT, 4-11 to 4-14, gl-2 (aiso see Applesoft; Autostart; BASIC; Integer; monitor; ROM) and data bus direction 4-11, 5-29, 5-31, 5-34 firmware peripheral card 4-14, 6-7, 7-20 and maximum PHASE 0 hold off 4-12, 4-22 and DMA Controller 4-31to4-32 and MMU propagation delay 4-13, 5-32 DOSHOSS 6-12 to 6-18 and MPU 1-4, 2-17, 4-2 to 4-4, 4-11 to 4-14 FIRST/SECOND/THIRD 40 5-8 to 5-19, 5-41 and READY 4-12, 4-22. G-3 Fischer. Dan 4-17 and X4, X5 jumpers 4-14, 4-22. 7-18. G-.3, 1-,3 FLASH signal 3-14,3-17.8-10,8-13 cycle stealing 4-11 to 4-14, 4-29, )rl-2 flash counter 3-14. 3-17 to 3-19 direct bus access 1-4.2-17 flashing text 1-8. 3-!7. R-S, 8-13 to 8-14 DMA IN/OUT signals 4-14, 7-18, 7-20 flip-flop gl-3, E-2 DMA' signal 4-3,4-11 to 4-14, 5-29 to 5-34. 7-19 floating bus 4-9, 5-32 to 5-38, 5-40, 7-24 to 7-26 from video scanner 4-11.8-1 to 8-3 floatinK point routines 6-6,6-7 priority chain 4-14, 4-31, 7-18. 7-20 simultaneous DMA 2-9, 4-11, (rl-6 floppy disks 9-2. 9-25 (also see video scanning) Fourth Dimension 9-48 DOS 9-1 to 9-5, 9-26 FRCTXr signal 3-18, 6-2. 7-27. 7-28. 8-19 to 8-21 and 1/0 links 7-22 to 7-23 frequencies. Apple 3-4 to 3-5, 3-!7, 3-28 ProDOS 7-22 to 7-23, 9-4, 9-26, 9-42 to 9-45 game t/0 extension jack 1 - 1 i , 7-5 to 7-7, 7-33 3 9-2,9-26 Sfame I/O socket 1 - 1 1 , 7-S to 7-7. 7-33 to 7-36 3.2 9-26,9-36 3.3 7-22 to 7-23. 9-4, 9-26, B-34 to 9-42 Kates (logic) 2-10, gl-3. El to E-5 tiencral Instrument 6-5. 7-12 DOS data formats 9-2 to 9-5. 9-25 to 9-28, 9-33 address field 9-2. 9-4. 9-26 to 9-28, 9-39 to 9-42 (;ETLN 7-22 blocks 9-4,9-43 CrRAPHlCSmode HIRES) 1 -7 to 1-9. 8-7. 8-27 to 8. ■!7 [also see LORES; bootstrap incompatibility 9-26, 9-34 checksum 9-26, 9-28. 9-4 1 to 9-42 graphics pad 1-11 data field 9-2, 9-26 to 9-28. 9-.39 to 9-42 CRAPHICS time 8-] 1 to 8 13 data field misalignment 9-41, 9-42. 9-44 gated r.R+2' signal 3-18 to 3-22, 8-1 1 to 8-12, 8-19 to S-21 field identifiers 9-26 to 9-28, 9-32 to 9-.34 (;R, (;R+1. (;R+2 siKnal.s 7-27, 8-10 to 8-12, 8-.S7 to 8-39 half/quarter track 9-13 (;TE MicrocircuiLs 4-22 read syncing leaders 9-25, 9-27, 9-28, 9-30 restrictions 9-26 HAL (Hard Array IjOgic) 1-5. 3-20 to 3-22. gl-3 (also .we PAL; timinc sector 9-2 to 9-4 generator) Hardware Ajiplications sector interleaving 9-,39, 9-42, 9-43, 9-45 Aceessinf^ tlie alternate keyboard set 7-37 to 7-38 track 9-2, 9-7 Applesoft emulator for the timing HAL ,3-29 to 3-32 track to track synchronization 9,39, 9-43 D MAnual t:ontroller 4-29 to 432 write tables 9-2B Disk drive write protect bypass switch 9-46 to 9-48 4-4 coded data 9-41.9-42 DOSHOSS 6-12to6-lH (also see RWTS programming examples) Extendinfr the game I/O socket 7-33 to 7-36 DOSHOSS 6-12 to 6-18 Modifying: the system monitor 6-10 to 6-11 DOS Protjm m mer 'x Miiiiiml fn r 11. Ih. II, 9-34 Programming screen character sets in EPROM 8-40 to 8-43 HBL (Horizontal BLankinft) 3- 15 to 3-16. 8-3 to 8 6. 8-10 DOS TOOLKIT display DOUBLE-RES 3-29,8-41 modes' 1-7 to 1-8, 5-7, 8-19 to 8 24 and memory scanning 5-10 to 5-19. 5-41 to 5-42, 1-4 Dvorak keyboard layout 1-10, 7-14, 7-16 to 7-17, 7-37 HIRES40rightsidecut-24, gl-3 ENVID' signal 7-U, 7-27, 7-37. 8-10. 8-11. G-2 HIRES graphics 1-7 to 1-9, 8-31 to8-37 EN80' signal 5-3 to 5-5, 5-.TO to 5-38, 7-27 character sets 3-29.8-41 colors 1-8 to 1-9.8-7. 8-32 to 8-.37 EPROM el-3 deiaved video 1-9. 8-9, 8-22 to 8-24, 8-32 to 8-35 adaptor 6-11. 7-38. 8-19, 8-42 HIRKS40 mode 1-7 to 1-9, 8-32 to 8-35 compatibility with ROM 6-2 HIRES80 mode 1-8 to 1-9, 8-.35 to 8-37 creation for system monitor 6-10 to 6-11 interference 8-33 to 8-35 DOSHOSS 6-12 to 6-18 keyboard 7-9 to 7-10, 7-37 to 7-38 memory representation 8-8 to 8-9 memory scanning 5-11 to 5- 19. 5-40 to 5-42 programmins screen cliaracter sets 8-40 to 8-43 resolution 18 to 1-9, 8-32 to 3-37 Espinosa. Chris H-2 Eurocolor 8-17 right side cutoff .3-29. 8-22. 8-24, S-33 fo8-35 (al.sosee LORES; video) European/export Apples (see PAL motherboartlt HIRES lOU Softswitch 7-3 to 7-6, 8-19 to 8-21 exdusive-OR gate g!-3, E-3 HIRES MMU Softswitch 5-22, S-25 to 5-27, 5-,30to5-33 expMsianROM 6-4 (see also E/0 STROBE' ROM) HIRES TIME 5-6, 8-37 to 8-39 fan, cooling 10-3 to 10-4 and memory scan 5-6. 5-7, 5-13 to 5-19 FCC regulations 8-3 history 5-20. 6-6 to 6-9, H-1 to H-2 FILER program 9-4. 9-42 to 9-43 Holt, Rod 9-16. H-2 Homebrew Com puter C 1ub HI firmware 1-3, 2-6, 6-6 to 6-9 horizontal and 1/0 7-20 to 7-23 blanking (sec HBL) bootstrap 4-15, 9-9 to 9-12 diagnostics 6-10, 10-6 to 10-8 counter 3-13 to 3-16 interrupt handling 4-15 to 4-21 upgrade 4-18 to 4-20, 6-8 to 6-10, 10-6 retrace 8-11,8-16 period 3-12.3-13,5-13,8-5,8-6 40-column firmware scan 3-13 to 3-17, 8-5,8-6, 8-16,8-17 6-8, 8-14, 8-40 sync 3-12, 3-16. 5-15 to 5-18, 8-4 to 8-6, 8-10 ifai 4 Understanding the Apple He HPE' (hnrizontal preset) 3-13. 3-14. 5-19 IRQ' (Interrupt ReQuest) 4-2 to 4-4. 4-15 to 4-21, 7-18, 7-19 HRC(J (HIRES Character Generator) 3-29. 8-41 Jobs, Steve H-lU)H-2 HO 3-5 to 3-7. K-21. 3-22. 7-27. 8-lZ. 8-38 joystick 1-11, 7-6, 7-33to7-36,Kl-4 (also see paddles; timers) I/O (Input/Output) 1-7 to 1-11, 2-14 to 2-19, Chapters 7-9 alternate 10-3, jumpers G-2 to G-3 characters (XI, X2) 7-11, 7-37 to 7-38. G-2 and address decodiriK 2-in to 2-16, 7-1 to 7-4 and bus structure 2-14 to 2-19 Apple 1! Eurapple 8-17, 1-7 DMA (X4. X5) 4-14, 4-22. 7-18. G-3. 1-3 and firmware 7-21 to 7-23 ENVID' (X3) 7-37, 8-10, 8-11, G-2 Apple Il/Ile differerioes 1-5 to I-0 GR■^2(X7) 7-lS, 7-20, G-3 pame socket 7-5 to 7-7 keyboard CONTROL/RESET 7-10, 7-11, G-3 links (CSW and KSW) 7-21 to 7-23 SHIFT key mod (X6) 7-6, 7-7, 7-35. G-3 memory nnapp^d 2-14 serial I/O 1-10 to Ml?. 2-18. 7-1 lo7-9, 1-5 IK auxiliary RAM card 5-39 speaker 7-3 to 7-fi. 7-9 Kane, Gerry 4-12 timiniT 7-23 to 7-26 (also see auxiliary slot; cas.sette: disk: DMA; peripheral slots: video: kc.vbnard) keyboard 7-38 Kaypro 1-9 to 1-10, 2-16, 7-9 to 7-17 alternate characters 7-13 to 7-17, 7-37 to 7-38 I/O SELEfT' (i-4, 7-2. 7-4. 7-18 to 7-20 AKD line 2-16. 6-11, 7-3, 7-4, 7-12, 7-15 and disk fontroller 9-11. 9-12 A ppSe I I/IIe di fferenees 1-6 I/O STROBE' fi-l. 7-2. 7-4. 7-18 to 7-21 ASCII MO, 7-3, 7-9 to 7-17 protocol 4-19.4-20.7-21 auto repeat feature 2-!6, 3-17, 7-!5 I/O STROBE' ROM B-4. 7-20, 7 21 A UTOSTRB signal 3-!4, 3-17, 7-4, 7-15 IC Isee intCErated circuits) close/open Apple keys 1-10, 4-15, 7-7, 7-10 impedance 2-1 to 2-2. eI-3. E-2 CTRL required for RESET 7-10, 7-11, G-3 IN#n 7-20 to 7-23 Dvorak/QWERTY layout 1-10, 7-14. 7-16 to 7-17, 7-37 encoder 7-10 to 7-13 imlired addressing 4-S input buffer 6-7,7-22 INHIBIT' 5-24 to 5-34. 6-2 to B-4. 7-18 to 7-20. G-1 KBD' signal 2-16, 5-28 to 5-33, 6-4 to 6-6. 7-11 input iHiffer, f.ETLN 6-6, 7-22 keyboard ROM 7-9 to 7-17, 7-37 to 7-38, 8-18 Inptil/Output Isee I/O) keybciunce mask 7-10 to 7-12 INTCXROM soft switch 5-22. 5-28 to 5-34. 7-19 to 7-21 KEYSTROBE Softswitch 2-16, 7-3 to 7-5. 7-15 INTD^ROM .soft switch 5-20, .i-22. 5-Z« to 5-34, 7-19 to 7-21 KSTRB signal 3-14, 3-17, 7-3. 7-4, 7-11, 7-12, 7-15 numeric keypad 7-10, 7-11. 7-16 to 7-17, 7-37 IntcKcr BASIC 4-11. 6-6 to 6-8. g\-A operational summary 7-14 to 7-15 andDOSHOSS fi-12to6-ia SH I FT key mod 7-6,7-7, 7-35, G-3 iriteerated circuiLs 1-2, 1-1(1. jr!-4. E-2 special function keys 1-9 to I-IO, 7-10. 7-11 lOU 1-5.1-6,5-6,7-4,8-10 timing 6-4 to 6-6, 7-12 MMU 1-5.5-30,5-31 KEYSTROBE Softswitch 2-16, 7-3 to 7-S, 7-15 troubleshooting 10-4 to 10-11 1«R8 HAL/PAL .3-18 to 3-22 Kraul, Doug H-2 2365 ROM 6- 1 to 6-6 KSTRB signal 3-14. 3-17, 7-3, 7-4, 7-11, 7-12, 7-15 34 70 flopp.v read in terface 9-8 to 9-9 KSW (Keyboard input SWitch) 7-21 to 7-23 3600 keyboard encoder 7-10 to 7-13 Language card (see RAM card) 558 quad timer 7-6 to 7-8 6309 PROM 9-11.9-21 LDPS' 3-4 to 3-11, 3-20 to 3-22, 7-27, 8-10, 8-14, 8-21 to 8-39 650 demodulator 8-17. 8-lS Lechner, Pieter 9-1, 9-34 6502 MPU 4-1 to 4-28. CI to C-7 LED, self lest 7-6. 7-9, 10-8 65C02MPU 4-21 to 4-28. C-7 to C-I5 6664 dynamic RAM 5-1 to 5-4, 5-34 to 5-38 links, I/O 7-21 to 7-23 74LS148 priority encoder 4-29 to 4-30 Ux)ir Dntnhmk E-2 74LS74 dual D flip-flop 8-18, E-2, E-4 logic equations (Boolean algebra) E-2 to E-4 74S109 3-18,3-19 timing HAL 3-20 to 3-22, 3-29 to 3-32 741 op amp 7-6,7-8 logic levels 1-2 to 1-4, 1-11, E-1 Intel 4-12.6-2 logic state sequencer 9-5. 9-11, 9-14 to 9-35 interlacing commands 9-15 freqt;ency 8-6, 8-48 decoding the contents 9-15 to 9-18 television scan 3-16, 8-6, 8-16, gI-4 listings 9-19,9-20 P6PR0M 9-11, 9-14 to 9-17 internal registers, 6502 4-9 to 4-10, 4-15 to 4-20 QAWAIT 9-29 to 9-31, 9-35 internal ROM 5-28 read pulse input 9-1 1. 9-15 to 9-16, 9-30 interpreter 4-11, g;l-4 READ sequence 9-5, 9-19, 9-20, 9-27 to 9-35 interrupts, 6502 4-2 to 4-4, 4-14 to 4-21 sequencing flip-flops 9-11, 9-14 to 9-15 in/out priority chain 4-16 to 4-17, 7-18, 7-20 WRITE PROTECT sequence 9-19 to 9-21 (also see IRQ'; NMI': RESET': BREAK) WRITE sequence 9-14 to 9-15, 9-19 to 9-25 inverse text 1-8, 8-8, 8-13 to 8-14. 8-26 logic symbols E-1 to E-5 inversion, logical 1-4, 4-6, E-2, E-4 long cycle 3-2 to 3 7, 3-19 lOU (I/O Unit) 1-5,1-6 and Apple frequencies 3-2 address decoding 2-12, 7-2. 7-4 and disk I/O 9-25 AO— A6, A7 address latch 5-6 and timing loops 3-28 and 6502 com mun ication 4-5 to 4-6 diagrams 1-6,5-6.7-4,8-10 flash counter 3-14.3-17 to 3-19 in AppleforII 3-7, 1-3 3-19 keyboard support 3-14, 3-17, 7-3, 7-4, 7-12, 7-15 reason power-up reset 2-6,3-14,3-17,4-2 LORES graphics 1-7 to 1-8, 8-27 to 8-31 RAM address multiplexing 2-7, 5-5 lo 5-7 abnormal 7 MHz LORES mode 8-22, 8-24 serial I/O functions 2-18, 7-3 to 7-5 colors 1-8, 8-7. 8-28 to 8-31, fig 8-11 soft switches 5-7, 7-3 to 7-5, 8-19 to 8-21 cyclic patterns 8-28 to 8-30, fig 8-11 tiining signals 3-11 HO/VO variations 8-12, 8-27 • : video generator 2-9, 8-2, 8-9 to 8-16 video scanner 2-7 to 2-9, 3- 13 to 3-17 LORES40mode 1-7 to 1-8. 8-28 to 8-29 '■ '•-' 4-bit adder 5-6, 5-9 LORESSOmode 1-7 to 1-8, 8-29 to 8-31 Vi:st!;= 50/60 Hi 3-4to3-5, 3-16tq3-17,8-iato8-17 representation memory scanning memory s to 8^-8 5-10 5-12. 6-40 to 6-4Z .iiv' ■■»" !^ index 5 resolution 1-8, 8-31 (also see HIRES: video) bugs 4-21 clock pulses 3-4to3-10. 4-2, 4-5to4-9 LSTTL 1-10. 3-19, 5-S2.jrl-4 (alsoseeTTLl connections 2-20, 4-3, 4-4, 7-18 luminance siRnai 8-6 to 8-7, 8-17 to 8-19. 8-47 to 8-48 data sheet C-1 to C-7 instruction details 4-23 to 4-27. 9-23. C-6 machine cycles 3-4 to 3-10. 4-5 to 4-9. s?1-4 (also see ionft cycle) internal registers 4-9 to 4- 10. 4-14 to 4-20 interrupts 4-2 to 4-4, 4-14 to 4-21 machine language 4-9 to 4-10, (fl-4 machine cycle ,3-4 to 3-10. 4-5 to 4-9 machine state byte 4-19 manufacturers 4-1, C-1 maintenance and care 10-1 to 10-11, 1-7 maximum clock holdoff 4-12, 4-22, C-5 Markkula, Mike 9-1. H-2 memory usage 1-2 to 1-3, 4-5 McGraw-Hil!. [nc. 4-12 programming 4-9 to 4-11, F-2 to F-3 MC6800MPU 4-5 related signals 4-2 to 4-4 MD IN/OUT signal 2-16, 2-18. 5-28 to 6-31. ,'5-34, 7-15. 7-18 7-24 signals 4-2 to 4-4 to 7-26 stack 4-5, gl-7 MDO— MD7 (see data bus) timing 4-6 to 4-9, C-1 to C-6. 1-.3 (also see DMA: interrupts: timing diagrams) memory 1-3. 2-6 cell 2-7.5-2. Kl-4 MPU, 65C02 4-21 to 4-22 display areas 1-7 datasheet C-7toC-15 display representations 8-8 to 8-9 instruction details 4-26 to 4-28 inhibiting 5-24 to 5-34, 6-2 to 6-4. 7-19 multiplexed RAM address (RA0-RA7) 2-7, 2-20, ii-4 to 5-7, 7- location 2-7.5-2 27 (also see RAM addrcs.s multiplexing) management 2-10 to 2-12, 5-20 to 5-34 multiplexing gl-5 pages 4-5, gl-5 data bus 2-9 scanning 1-7 to 1-8. 5-5 to 5-20, 5-40 to 5-42 RAM address 2-7. 5-2 to 5-9. 1-2 scanning maps 5-11 to 5-!9, 5-41 serial inpuLs 2 18, 7-5 to 7-7 6502 usage 1-2 to 1-3. 4-5 (also see RAM: ROM; MMU: DMA) NANDgate gl-5.E-2. E-3 National Semiconductor B-1, E-2. H-2 memory mapped I/O 2-14. 4-5. gl-4 (also see address decoding:) NCR eorp. 4 21 to 4-22. 4-27 to 4-28. C-I. C-7 to C-14. 1-4 memory mapped video 1-7, 8-1 to 8-2, 8-8 to 8-9, gl-4 microprocessing unit (see MPU) Nintendo \i-l Microsoft 4-12,4-31.6-6,8-1 NMI' (Non-Maskable Interrupt) 4-2 to 4-4, 4-15 to 4-17, 7-lK, 7-19 Mini-Assembler G-6to6-7 NMOS integrated circuits 4-21. 6-1 MIXED mode 1-7,8-11.8-19 NOR gato gl-5, E-3 normal text 1-8, 8 8, 8-13, 8-26, H-40 scanning 5-7, 5-J3 to 5-19 switching 3-15 to 3-16. 5-7, 8-37 to 8-39 NTSC television 1-7, 8-3. 8-6 to 8-7 MIXED soft switch 7-3 to 7-5, 8-19 to 8-21 number systems F-1 to F-3 MMU (Memory Management Unit) 1-5. 5-20 to 6-34, i-4 numeric keypad 7-10, 7-11, 7-16 to 717, 7-37 address decoding 2-10 to 2-12. .5-30, 7-2 object program 410 to 4-1 1. gl-5 aux/motherboard RAM management 5-24 to ,5-27 octal number system gl-5, F-2 data bus management 2-10 to 2-12. 5-21 to 5-.33. fi-2 Ohio Scientific 4-1 diagram 5-29 to 5-32 high memory management 5-20 to 5-24. 6-2 to 6-4 Oki Semiconductor 4-9 I/O (SCXXX) management 5-28, 6-2 to 6-4 op code 4-9 to 4-!(l, 4-23 to 4-28. gl-5 propagation delay 4-12. 4-13, 5-.32 op code fetch 4-4 RAM address multiplexing 2-7. 5-5 to 5-7 open Apple key 1-10, 4-15, 7-7. 7-11. 10-7 Rev A/ Rev B G-1 open collector 4-4 soft switches 2-!2. ,5-20 to 5-.34, 10-6 to 10-7 operand 4-9 to 4-10. gl-5 timing signals 3-11 modulation 1-7. 8-3, 8-17. 8-47, g!-4 (also see RF modulator) OR gate Kl-,5, E-2, E-3 Osborne. Adam 4-12 monitor, system 1-3, 4-15, S-6 to 6-11, g!-4 IMuiriH' i &• n Bit Mii-ri,iiroiT!ixi>r Hiiiiilli-iitl: 4-12 Autostart 4-15.6-7,6-8 output enable 2-2 to 2 3. E-2. E-3 (also see tri-stale; data bus in ROM 1-3, 2-6, 6-6 to 6-7 management) modifying 6-10 to 6-11 old Apple II monitor 6-6 to6-7, 7-21 paddies Ml, 7-5 to 7-7 monitor, video 8-3, 8-7, 8-9, 8-33, gl-4 and game socket extender 7-33 tt) 7-36 Monolithic Memories 3-20, B- 1 programming 7-24 to 7-27 MOS integrated circuit 1-10, 5-,32, 6-1. gl-5 quad timer 7-6 to 7-8 MOS Technology 4-1, 4-6 to 4-7. 4-12. C-1 pages, di.splay 1-7, 5-7, 8-19 to 8-21, gl-5 most significant bit (MSB) 2-2. gl-5 (also see BYTE FLAG) pages, memory 4-5. gl-5 (also see memory scanning) PAGE2 lOU soft switch 1-7. 5-7. 7-3 to 7-5, 8-19 to 8-21 motherboard 1-1, gl-4 I/O l-10tol-ll,7-lto7-9 PAGE2 MMU soft switch 5-22, 5-25 to ,5-27, 5-30 to 5-33 part number G-1 PAL (Programmable Array Ijogic) 3-20 to 3-22, gl-6 (also see revisions G-1 to G-3 HAL: timing generator) (also see revision) PAL motherboard 1-7, 8-16 to8-19 Motorola 4-5,4-12.9-8 alternate characters 7-14, 8-41, G-2 mouse text 6-9, 8-25. 8-41 PAL TV system 1-7, .3-4 to 3-5, 8-16 to 8-19 MPU (Microprocessing Unit) 1-2, 2-6, gl-4 signal frequencies 3-4 to 3-5, 3-17, 3-28 MPU. 6502 4- 1 to 4-32, C- 1 to C-7 revision A/B G-1 to G-3 advantages/disadvantages 4-10 parallel data transfer 1-10, g)-5 and Apple I HI PEEK 4-25 and bus structure 1-2, 2-6, 2-20 peripheral address decoding 2-10 to 2-12, 7-1 to 7-4 and DMA 4-11 to 4-14 peripheral card check 10-8 and peripheral slots 1-3 to 1-4, 4-3, 4-4, 7-18, 7-19 peripheral card failures 10-8 to 10-10 Apple Il/IIe differences 1-3 peripheral data bus (D0-D7) 7-6. 7-!5, 7-18, 7-24 to 7-26 6 Understanding the Apple He periphera] data bus driver 2-16, 7-15, 7-18. 1-2 radio frequency (RF) 1-7, g-3, 8-47 to 8-48 timinp and control 5-29, 7-24 to 7-26 Radio Shack 10-6 write cycle isolation 2-16, 7-24, 7-25 RAM (read/write memory) 1-3, 2-20, 5-1 to 5-44, g|-6 (also see MD IN/OUT') and Apple bus structure 2-6 to 2-10, 2-20 peripheral slots 1-3 to 1-4, 7-15 to 7-26, 1-6 and MPU communication 5-3 to 5-5, 5-32 to 5-38 and address decoded si^rnals 7-2, 7-4. 7-18 to 7-20 and 6502 memory usage 4-5 and bus structure 1-.? to 1-4. 2-16. 2-20, 7-15, 7-18 Apple Il/IIe differences 1-4 and I/O links 7-21 to 7-23 auxiliary card 5-1 to 5-5, 5-24 to 5-27, 5-39 connections 2-20, 4-S. 7-2, 7-4. 7-15 to 7-20 CAS' ,3-4 to 3-11, 5-2 to 5-5 reliability 10-2 chip organization 2-9,2-20,5-3,5-4 (also see auxiliary slots, I/O) connectiotis 2-20. 5-3 to 5-5 Periteljack 8-17 data distribution 2-9 to 2-10. 5-3 to 5-5, 1-2 phase relationships, color 3-7, 3-10, 3-19, 8-27 to 8-37. 1-7 dynamic RAM chip 5-1 to 5-4, 5-34 to 5-38 PHASE 0 3-2 to 3-10, 2-20 to 3-22, 4-2 to 4-9, 7-18, 7-27 (also see early write cycle 5-34 timing diagrams) inhibiting 5-24 to 5-34, 7-19 R/W 5-,S. 5-4. 5-34 to 5-35 PHASE 1, Apple 3-2 to 3-10, 3-20 to 3-22, 4-6, 7-18. 7-27 R/W'80 5-4. 5-5, 5-36 to 5-38 PHASE 1,6502 4-2 to 4-8, 1-3 PHASE 2 4-2 to 4-9 (also see timinifdiaKrams) RAM bus 2-2 RAS' .3-4 to 3-1 1, 5-2 to 5-6 phases, stepper motor 9-5 to 9-8, 9-11 to 9-13 reading video data from program 5-40 to 5-44 PICTURE, PICTURE' sisnais 7-27, 8-3, 8-7 to 8-17, 8-24 to 8-36 refreshing of 1-3, 5-3, 5-19 to 5-20. 1-4 piffeonhole computer 2-^ scanning (sec memory scanning) POKE 4-25 static RAM chip 5-38 positive ioKic 1-3, ftl-5. E-1 TCAC/TOFF 5-35, 5-37 potentiometer (pot) 1-11,7-7 (also see paddles) timing 5-32 to 5-38 video data latches 2-9 to 2-10, 2-20, 5-2. 5-3 power supply l-ll,f^l-G reliabilit.v 10-3 RAM address multiplexing 2-7, 5-2 to 5-9, 1-2 to disk drive 9-5.9-6 address assignments 5-6 to 5-10, 5-19 to 5-20 to peripheral slots 7-15, 7-18 and bus structure 2-7 troubleshootinsr/failures 10-8 to Ifl-9, 10-11 circuit diagram 5-6 FIRST/SECOND/THIRD 40 5-8 to 5-19, 5-41 power-up byte 4-15,6-12 high RAM bank control 5-5 to 5-7. 5-24 power-up reset 2-6, ,3-14, 3-17, 4-2, 6-12, 9-13 on disk controller 3-17, 9-11. 9-13 HIRES scanning 5-11 to 5-19. 5-40 to 5-42 PR#n 7-20 to 7-23 MIXED mode .scanning 5-7, 5-13 to 5-19 offset generation 5-8 to 5-9 PREAD 7-29 to 7-30 RA0-RA7 2-7, 2-20, 5-4 to 5-7, 7-27 prime (') notation 1-4. E-4 TEXT/LORES scanning 5-10 to 5-12. 5-40 to 5-42 priority chains 7-18, 7-20 UNUSED 8 ,5-8, 5-1!, 5-14, 5-19, 5-41 DMA 4-14, 4-30 to 4-32 RAM card, 16K 5-22 to 5-24, 6-8, 1-4 interrupt 4-16 RAMRD/RAMWRTsoft switches 5-22 to 5-33 processor status rcRister 4-9 to 4-10, (fl-7 random access memory 1-3, 6-1. gl-6 (also see RAM; ROM) ProDOS 7-22 to 7-23, 9-4. 9-26, 9-42 to 9-45 RAS' 3-4 to 3- 11 , 3-20 to 3-22. 5-2 to 6-6 PrnDOfi Tt'chnimt Refercme Maiiml 9-34 RAS'CAS'/RAS' only refresh 5-3 program counter 4-9 to 4-10, 4-15, 4-19, frl-6 raster 3-12, gl-6 projrramminsr 4-9 to 4-1 1 RAO— RA7 (see RAM address multiplexing) (also see memory seanniiiK maps; software applications) RA9,RA10 signals 7-27, 8-9 to 8-14 propaKation delay 3-7, gl-6 read cycle 2-5, 2-6, 5-34 to 5-38. 7-24 to 7-26 CAS' 1-3 read pulse (see disk topics) in timing generator 3-7, 3-8, 3-20 READ sequence (see logic state sequencer) MMU signals 4-12.4-13,5.32 (also see timinK diagrams) read-modify-write instructions 4-22 to 4-28, gl-6 read/write control (see R/W) pull-down resistor 7-7, 7-10, 7-19, 7-34 read/write memory (see RAM) pull-up resistor 4-4. 4-32, 7-10, 7-19, 8-11 READY 4-3, 4-4, 4-21, 7-18, 7-19, G-3 pushbutton inputs 1-1 1, 7-5 to 7-7 and DMA 4-12, 4-22, G-3 and ganne I/O ex ten sion 7-33 to 7-36 and open/close Apple keys 7-7, 7-10. 7-11 refresh ing RA M 1 -3. 5-3, 5- 19 to 5-20, 1-4 and SHIFT key mod 7-6,7-7 reliability, Apple He 10-1 to 10-4, 1-7 P5 PROM (see Bootstrap ROM) repair, Apple He 10-4 to 10-11 P6 PROM (see logic state sequencer) RESET' 2-6, 4-2, 4-3. 4-14 to 4-15. 7-11 and Autostart monitor 4-15,6-11,9-12 quad timer 2-20. 7-6 to 7-8, 7-29 to 7-32 (also see paddles: timers) and disk controller 9-12. 9-13 Quality Software 9-1. 9-34 and high RAM 5-23, 5-24, 6-8 (fuiKLoader 6-18 and lOU 3-14, 3-17, 4-2. 4-3, 7-3, 7-4 Quinn, Peter H-2 and MMU 4-14 to 4-15. 5-29 Q3 signal 3-4 to 3- U , 3-20 to 3-22, 7-18, 7-27 and peripheral slots 1-4.7-18,7-19 and auxiliary RAM 5-3, 5-35 to 5-38 and soft switches 5-29. 5-30, 7-3. 7-4, 7-37 and 6502 4-3, 4-4, 4-15 to 4-16 R/W 1-2. 2-6 to 2-7, 7-18, 7-27 handler 4-15, 5-28. 6-11, 7-37 and address bus 2-2, 2-6 to 2-7. 4-2 to 4-4 hard vector 2-6. 4-14 to 4-15 and address decoding 7-2 keyboard jumpers 7-10, 7-11, G-3 and RAM 5-3 to B-5. 5-34 to 5-37 modified handler 6-11 and ROM 6-4 power-up (see power-up reset) MPU connection 4-2 to 4-4 (also see timing diagrams) priority 4-20 soft (RAM) vector 4-15 R/W'80 5-4. 5-5, 5-36 to 5-38, 7-27 revision A/B G-1 to G-3 R.H. Electronics 10-3 alternate characters 7-11, 7-13. 7-37 to 7-38. 8-11 tndex 7 ENFIRM/FRCTXr 6-2, 6-3, 7-28. 8-19 to 8-20 Modifying the system monitor 6-10to6-n timing HAL 3-20 Programming DOUBLE-RES displays in BASIC 8-44 to 8-46 X3 jumper 8-10,8-11 Programm ing the game paddles 7-29 to 7-32 X7 jumper 7-18 Readi ng video data from a program 5-40 to 5-44 RF leakage 8-3,1-1 Switching screen modes in timed loops 3-23 to 3-2T RF modulator 1-7.8-3,8-47 6502/65C02 instruction details 4-23 to 4-28 Rockwell International 4-1, 4-6 to 4-7, 4-12. 4-21 lo 4-22 4-27 to 4- source program 4-10 to 4-11, gl-6 28, C-ltoC-5, 1-4 Southern California Research Group 6-18 ROM (Read Only Memory) 1-3, 6-1 to 6-18, gl-6 speaker MO, 7-4 to 7-6. 7-9 and BASIC 1-3, 2-6, 6-6 to 6-7 special function keys 1-9 to 1-10. 7-10, 7-11 and bus structure 2-6. 2-20 SPKR signal 7-3 to 7-6, 7-9 and I/O SELECT' 6-4,7-20 stack, 6502 4-5, 4-15 to 4-20 and monitflr 1-3, 2-6, 6-6 to 6-7 andR/W 6-4 stack pointer 4-5, 4-9 to 4-10, 4-14 and 6502 memory usage 4-5 stacked interrupts 4-16 Bootstrap (P5) 9-9 to 9- S2 state machine (see logic state sequencer) checksum 6-11.10-7 status register. 6502 4-9 to 4-10, 4-14 to 4-20 chip selects 6-2 connections 2-20. 6- 1 to 6-4 STEP utility 6-7,6-10 CI— DF and EO— FF ROMS 2-20, 6-1 to 6-6, 6-8 stepper motor 9-2. 9-5 to 9-7, 9-13, 9-38 firmware 1-3. 2-6, 6-6 to 6-9 strobe g]-7 1/0 STROBE' ROM 6-4, 7-20, 7-21 CAS' 3-4 to 3-1 1,3-20 to 3-22 5-2 to 5-5 inhibiting 5-28, 6-2 to 6-4. 7-19 C040 STROBE' 1-1 1, 4-25, 7-2 to 7-6 keyboard ROM 7-9 to 7-17, 7-37 to 7-38, 8-18 1/0 STROBE' 6-4, 7-2. 7-4. 7-18 to 7-21 ROM bus 2-2 KEYSTROBE soft switch 2-lB, 3-17, 7-3 to 7-,5, 7-12, 7-15 timing 6-4 to 6-6 KSTRB' signal 3-14, 3-17, 7-3, 7-4. 7-12. 7-15 video ROM 8-9 to 8-14, 8-18, 8-26. 8-40 to 8-43 RAS' 3-4 to ,3- 1 1 , 3-20 to 3-22, B-2 to 5-8 write cycle (just kidding) SUMA3-SUMA6 5-6, 5-8. 5-9 (also see firmware: nionitor) SWEET 16 6-6,6-7 ROMEN)', R0MEN2' signals 5-27 to 5-33, 6-2 to 6-6, 7-27 switch bounce 4-29, 7-10 to 7-12 ROW address 2-7,5-2 to 5-7. 5-19 to 6-20 SYNC, video 7-18. 7-27. 8-3 to 8-6, 8-10. 8-lB RWTS 9-4 SYNC. 6502 4-3. 4-4. 7-18, 7-19, [-3 data formats 9-25 to 9-27 flowchart 9-37 Synertek 1-6, 3-7, 4-t, 4-6 to 4-7, 4-12. 6-1.6-5, C-l, H-2 programming examples 9-34 to 9-42 Slittrlirt: Pntttrn uttii htt; Mniutnl 4-25 RWTS/DIIDD differences 9-42 to 9-45 write tables 9-26 television Sander. Wendel H-2 frequency interlace 8-6,8-48 frequency response 8-7. 8-33. 8-47 to 8-48 scan counter (see video scanner) Scott. Mike H-2 input 1-7,8-3 processing 8-3 to 8-7, 8-47 to 8-48 screen display 1-7 to 1-9 scan interlace 3-16, 8-6, gl-4 mapping 1-7 to 1-8,8-1 to 8-2, 8-8 to 8-9 scanning 3-12 to 3-17, 8-3 to8-6, 8-16 memory display areas 1-7 syne 3-12 3-13. 8-3 to 8-6. 8-16. gl-7 memory maps 5-1 1 to 5-19. 6-4 1 systems .3-12, ,3-17, 8-3, 8-16 to 8-17 (also see video; NTSC; PAL; SfXAM) modes 1-7 to 1-9. 8-19 to 8-21 pages 1-7, 5-7. 8-19 to 8-21 temperature. ot>erating 10-3 to 10-4 screen splitting 3-23 to 3-27, 5-40 to 5-44 TEXT mode 1-7 to i -8. 8-24 to 8-27 soft switches 7-3 to 7-5, 8-19 to 8-21 alternate characters 8-8. 8-40 to 8-43, (5-2 (also see memory; video; LORES: HIRES: TEXT) ASCII 1-8.8-13,8-15,8-25,8-40 SECAM (sequential color and memory) 8-17, gl-6 characters 8-8.8-15,8-25 secondary buses 2-7 memory representations 8-8 SEGA. SEGB, SEGC signals 7-27, 8-10, 8-12. 8-21. 8-37 to 8-39 memory scanning ,5-10 to 5-12, 6-40 to .5-42 serial data transfer 1-10. gl-6 norm/inv/flash 1-8,8-8,8-13.8-40 serial I/O MO to 1-11, 2-18, 7-1 to 7-9. 1-5 (also see I/O) patterns 8-25,8-40mode TEXT40/TEXT80 1-7 to 1-8, 8-20. 8-23, 8-26 serial input multiplexor 2-18, 2-20. 7-5 to 7-7 80-column capability 1-8. 7-23. 8-19 to 8-27 serrations 8-4, gl-6 80-column firmware 6-8, 6-9. 7-21, 7-2;i SET OVERFLOW 4-4.1-3 TEXT soft switch 7-3 to 7-5, 8-19 to g-21 ti mers SHIFT' signal 7-6. 7-7. 7-10, 7-1 1 SHIFT key modification 7-6, 7-7, 7-35. G-3 disk controller 9-U, 9-13 Shagart 9-2.9-16,9-43 paddles 7-6 to 7-8, 7-29 to 7-32. 1-5 Siemens 9-48 timing diagrams and descriptions AY -5-3600 keyboard encoder 7- 12 simultaneous DMA 2-9,4-11, gI-6 diiik controller soft switches 9-21 to 9-23 SINGLE-RES display modes 1-7 to 1-8, 8-19 to 8-24 disk read pul.se generation 9-8 to 9-9 slot ROM 6-28,6-4 DMA 4-12 to 4-13 SL0TC3R0M soft switch 5-22. 5-28 to 5-34, 7-!9 to 7-21 HI RES video output 8-31 to 8-37, fig 8-13 Smith. Burrell H-2 I/O 7-23 to 7-26 soft switches 1-6. gl-6 LORES video output 8-27 to 8-31. fig 8-9 and RESET 5-29, 5-30. 7-3. 7-4. 7-37 MIXED mode switching 8-37to8-39 disk controller 9-1 1 to 9-U MMU/IOU timing signals ,3-U display mode 7-3 to 7-5, 8-1 9 to 8-21 RAM 5-2, 5-32 to 5-38 lOU 5-7, 7-3 to 7-5. 8-19 to 8-21, 1-5 READ sequence performance 9-32 to 9-,'53 MMU 2-10 to 2-12, 6-20 to 5-34 ROM 6-4 to 6-6 reading 5-20. 5-22, 5-30. 7-3 to 7-5. 1-5 TE XT video output 8-23 to 8-27 SOFTALK 4-17,5-40 timing generator signals 3-2 to 3-12, 3-32 6502 4-5 to 4-9, C-l to C-7 Software Applications Apple timing loops 3-28 timing generator 3-1 to 3-22 and video scanner 3-2. 3-3 ^kii,.. 8 Understanding the Apple He Apple II/I le d iffercnces 1-2 to 1-3 Apple Il/lle differences 1-6 to 1-7 hardware 3-19 to 3-22 data latches 2-9 to 2-10, 2-20, 5-2 to 5-4 overview 3-2 delayed HIRES 1-9. 8-22 to 8-24, 8-32 to 8-35 propaEation delay 3-7. 3-8. 3-20. 1-2 HIRES generation 8-31 to 8-37 signal descriptions 3-2 to 3-12 HIRES40 interference 8-33 to 8-36 signal distribution 3-7. 3-9 lOU circuits 8-10 signal frequencies 3-4 to 3-5. 3-17. 3-28 load/shift register 8-10,8-14 tim ittft d iagrams 3-5 to 3-7, 3-32 LORES cyclic patterns 8-28 to 8-29, fig 8-1 1 timiriK HAL 1-5. 3-20 to 3-22. 3-29 to 3-32, G-1 LORES generation 8-27 to 8-31 (also see long cycle; timine diagrams) MIXED mode switching 5-7,8-3710 8-39 timing loops ,1-23 to 3-28. 4-32. 5-41 . 9-25 mode configuration 8- 19 to 8-21 , 8-26, 8-27, 8-31 norm/inv/flash 1-8, 8-8. 8-13, 8-40 tOKEle outputs 2-18. 7-3 to 7-5. 7-9 TEXT generation 8-12 to 8-13. 8-23 to 8-27 TRACE utility 6-7.6-10 timing signals S-21 to 8-24 trademarks B-1 video ROM 8-9 to 8-14, 8-18, 8-26, 8-40 to 8-43 transceiver (transmitter/receiver) 2-2 to 2 3 (also see bidirectional video scanner gating 8-9,8-10,8-16 bus driver) 3.56 MHz trap 8-18,8-19 tri-state bus drivers 2-1 to 2-3. 4-2 to 4-4 video scanner 1-5, 1-8, 2-9, 3-2, 3-13 to 3-19 tri-slate logic 2-1 to 2-8. ((1-7. E-2 and 50 Hz scanning 3-16 to 3-19, 8-12 to 8-14 troubleshootinE 10-6 to 10-11. i?l-7 feedback to video generator 3-2. 3-3, 3-5 to 3-7 truth lable.i E-1 to E-4 hardware 3-13 to 3-16 logic gating 8-9.8-10. 8-16. 8-37, 8-38 TTL (TVansistor Transistor Logic) 1-10. 3-19. E-2 (also see video generator) two state loftic 1-2.1-8.2-1 video signal components 8-4.8-10,8-18 chrominance 8-5 to 8-6, 8-17 to 8-19. 8-47 to 8-48 Ihiiln-stiiml'nin llw Ai,)ili- II 5-23. 5-40. 5-42. 6-12. 9-34. 10-3 COLOR BURST 3-15. 8-3 to 8-7, 8-10. 8-16 to 8-19 UNUSED 8 ,5-8. ,5-11.5-14. 5-19. 5-41 COLOR REFERENCE 3-4 to 3-10, 8-6 to 8-7. 8-17 USERl 7-19. 1-fi color subcarrier 8-17 to 8- 19. 8-47 to 8-48 luminance 8-6 to 8-7. 8-17 to 8-19. 8-47 to 8-48 VBL (Vertical BLanking) 3-15 to 3-16, 8-4 to 8-6. 8-10. 8-lT and memory seanninpr 5-10. 5-12, 5-18, 5-19, 5-41 PICTURE signal 7-27. 8-3. 8-7 to 8-17, 8-24 to 8-36 SYNC 7-18. 7-27, 8-3 to 8-6. 8-10. 8-16 andSOHji'OUs 8-16 VIDEO output 8-3 to 8-7, 8-10, 8-16. 8-18 poll i ng 3-23 to 3-27, .5-40 to ,5-44 . 7-3 to 7-5 WN DW 8-10. 8-11. 8-37 to 8-39 vectors, interrupt 4-14 to 4-20 vertical Video-7. Inc. H-2 VIDO— V1D7 (see video data) counter ,3-13 to 3-17 retrace 3-13, 5-13. 8-5. 8-6 VID7M signal 3-4 to 3-12. 8-10. 8-21 to 8-35 scan 3-13to3-17. 8-5. 8-6.8-16 VPE' 3-13 to 3-17 s.vnc 3-12. 3-16. 5-18, 8-4 to 8-6. 8-10, 8-16 Watson. Allen III 8-37. 8-45 video 8-1 to8-48, gl-7 and export Apples (see PAL motherboard) Wiggington. Randy 9-16. H-2 and RF modulator 1-7, 8-,3, 8-47 wire-OR (collector OR) 4-4, 7-19. gI-7 black reference 8-3 WNDW signal 8-10. 8-11. 8-37 to 8-39 blanking 3-12, 8-4 to 8-6, 8-26 Worth. Don 9-1.9-34 color signals 8-6 to 8 7, 8-16 to 8-19, 8-27 to 8-37 Wozniak. Steve 1-1. 4-12. 5-8, 6-6, 9-16, 9-26. H-1 to H-2 colors 1 -8 to 1 -9. 8-7, 8-27 to 8-37 write cycle 2-5, 2-6. 4-21.5-5. 7-24 (also see timing diagrams) composite video 8-3, 8-6 to 8-7, gt-2 displa.v (see screen display) write protect switch 9-6 to 9-8, 9-13 to 9-14, 9-21 generation (see video generator) installing (see on disk also disk I/O) drive 9-46 to 9-48 horizontal period 8-11.8-16 mapping 1-7 to 1-8, 8-1 to 8-2. 8-8 to 8-9 X-register 4-9 to 4-10 modes 1-7 to 1-9. 3-19 to 8-21 monitor 8-3.8-7.8-33 Y-register 4-9 to 4-10 NTSC l-7.8-3.8-6to8-7.8-16to8-19 zero page addressing mode 4-5 PAL 1-7, 3-4 to 3-5. 3-17, 8-16 to 8-19 programming 1-8. 8-1. 8-8. 8-20. 8-44 Zilog 4-12, B-1 retrace 3-12 to 3-13, 8-5.8-6 Z80MPU 4-1, 4-11, 4-12 scanning (see memory scanning, television scanning) Z80 softcard 4-12, 4-31 to 4-32, 7-19 SECAM 8-17 3,5M (see COLOR REFERENCE) soft switches 7-3 to 7-5, 8-1 9 to 8-2 1 7M 3-4 to 3-10. 3-19 to 3-22, 7-18, 7-27 syncing serrations 8-4 (also see HIRES; LORES: MfXED; screen; television: TEXT) 14M 3-4 to 3-10. 3-19 to 3-22, 7-27, 8-10 video data 2-9 to 2-10 40-column firmware 6-8, 8-14. 8-40 6502 MPU (seeMPU) and peripheral cards 5-5, 7-24 to 7-26 bus (VID0^VID7) 2-9 to 2-10, 5-4, 7-27, 8-9 to 8-14 80-column card (see auxiliary slot) distribution 2-9 to 2-10, 5-3 to 5-5, 7-27. 8-10 80-eolumn firmware 6-8, 6-9. 7-21, 7-23. 8-14 latches 2-9 to 2-10. 2-20, 6-2 to 5-4 reading from program 5-40 to 5-44, 7-24 to 7-26 80COL soft switch 7-3 to 7-5, 8-19 to 8-21 VID7 delay generation 8-22 to 8-24. 8-32 to 8-34 80COL' signal 3-20 to 3-22. 7-4. 7-27 (also see timing diagrams) 80ST0BE lOU soft switch 5-7, 7-3 to 7-5. 8-19 to 8-21 video generation 2-20, 8-1 to 8-34 80STORE MMU Softswitch 5-22, 5-25 to 5-27, 5-30 to 5-33 and export Apples 8-16 to 8-19 80VID phantom soft switch 5-7 Understanding the Apple lie A Learning Guide and Hardware Manual for the Apple He Computer 'f M^rriwiAv l'^ Apptr He Irrtin rtiitimt iMUimfdm thr Mw.il ntt> tht mner »ijrt#

-su of the inner workings of the Appk 11 computer with an cv-en more detailed analysts of the Apple lie Now he has documented ha iindmp in a way that will benefit everyone interested in microcomputer technology t mdirummhmt ikt Appk Itt— • I)ucumcni»all nutihcrbcwriiCTrintitt. tjtifratni ind dncnptiont iti ibc innet • nrking^ofthc MMl . lOl . ftitJ iimitig HAL > DrMrnboditk conirulkf opcniicMt. incluiliaf prrtinutl) undocumcnied dctaik o4 Ibc togK • Reveal* pfoiouUy unnooced lealum ol Apple gnphm t'kplaimduuNe-fvt • f'tpUimdiffcTTncabeittvcn Ihe Apple II tad • Apple (onuimIk I) Mtfiwart and hardware Applicaliofi Notct iiKludinn I f'ROM mod*. di%k wnic protect mod. iplii wrren programminf . and ihe IX>S MOSS finnwit card mod • Inclttdc* a chapter on mainiraBncc thai ^ \ 1 pro\)de» timpk iroubk«h valuabk It n an Kkal h«*o4 for • (untUmcnub coune haicd on the Appk you Quflirry soFrw;aR€ Bpailif ISBN D-fl351-ft0in-7