@L}5 _$% l0$)$$Hȱ$ UhL" `e$$%`$%`  R@P!( L(1   Y I`  d  Ld M * @  $ % CC$$)%1 Udߥ$9%: !0 S$% DD˙`  }J)Lr d M * @  $ % CC$$)%1 Udߥ$9%: !0 S$%} DD˙`  }J)Lr J  ((  p L ()   J}L= ( L 0q A    IB JC;? D W } LL  ` W )LA!  ߰")-݆ p" } $G@LL 08`Q")<2Q0 -G$Ș݆ UL# ; p8(()(0ʥ)NQ` }$GȘ݆LU )L ݆ L GȘ ݆LL )W>Z   HH)H }p h  hyhy D L> L JJ    ! LA*` BF }7'8  M HN H` 8 Z  \LdJJ!"! GFE@F (!L }EE !E^ ^ E E7EȩEdE/EȩE  D } .L }  ;F d  ;?F7F? ( .   Z D LL d } . D  L    p  E` , d)  D L) 0BM݊L݉} ML  N݆ L NLML [ TEqEHȱEqEh 0Gȹ G} HLL GɛL  LFREE SECTORS G) *Gȩ GȽG GȌ*jj >G} C8jJ3j2CD( C202C ԠBX` N 1? l LlD:RAMDISK}.COMLu L1 L ;LHL  T`  `1  ɐ     `TU  } L ? .  t`GBJ ~DEHI B V0dV!}QDEHI VF9 ,0 ,0 s0hhL  L` H hDHEh"}DEL8HI4 0 HI,0 0  9 .G VLO#},0 L4*IJ`llD1:AUTORUN.SYSNEED MEM.SAV TO LOAD THIS FILE.D1:MEM.SAV J y08 B|DEHI$} V0 0`B;DEL`?<0LV`@ʆ v s? F0Ξ05: [ BDEHI%} VY8 B V  @  /DE `E:D1:DUP.SYSERROR-SAVING USER MEMORY ON DISKTYPE Y TO &}STILL RUN DOS B;DE J  (` 9 V⪍ ઍ  -'}LLu ÝDEHILV 9 .l 9 .l  `` s$B BH(}I|DE V BLV nB,DE JLV B V BLVDEIʩ BꭝLu  } 3E:}DISK OPERATING SYSTEM II VERSION COPYRIGHT 1984 ATARI CORP.A. DISK DIRECTORY I. FORMAT DISKB. RUN CARTRIDG*}E J. DUPLICATE DISKC. COPY FILE K. BINARY SAVED. DELETE FILE(S) L. BINARY LOADE. RENAME FILE M. RUN AT ADDRES+}SF. LOCK FILE N. CREATE MEM.SAVG. UNLOCK FILE O. DUPLICATE FILEH. WRITE DOS FILES P. FORMAT SINGLEL !N',}#"&))9(&*)/h)''-&؆莟R'S  vL/ˢ L }Insert DOS 2.0s, type Y Λx -}DEfHI 1莏#q! @ y0ɛ8A0,' ȅ 1 1ild! 1L!NO SUCH ITEMSELECT.} ITEM OR FOR MENU! 0 .z:*{}.|{ 1 0 0JB 18L%|DL/}%DIRECTORY--SEARCH SPEC,LIST FILE?[# 0 0 &|D3" 1L!NOT A DISK FILEN !B 1L!E# 1 !BD0}ED:}:1BJ|DE 1DEBHI 1 h0ߢ 0.1}  0?詛 1 y0YЛ 1 ;#L" ;#L! BL1TYPE "Y" TO DELETE...DELETE FILE SPEC2}COPY--FROM, TO?OPTION NOT ALLOWED736 FREE SECTORS COPYING---D1:DIRECK.COMl# 0|D .L/%#3}##JB|DE 1BHID#E 1#0: B 1L!#͑### B 1#c$0SY4}S1}:## # # .#Ƚ# # 𩛙## 1,#PD#ELJ- <.BJD#E 5}1 1HH 0hh|DL%1}:̳# L% #D#EL% 1 0 . .0O% 1L!WILD CARDS NOT A6}LLOWED IN DESTINATION 0 <.|K}N 2 FORMAT. t* 5) 1L!`) 0NΞ 0 L1) 1 L!BAD LOAD FILELOAD FROM WHAT FILE?) 0 ?}0#B 1L!WHAT FILE TO LOCK?) 0 0$B 1L!WHAT FILE TO UNLOCK?DUP DISK-SOURCE,DEST DRIVES?TYPE "Y" IF OK TO US@}E PROGRAM AREACAUTION: A "Y" INVALIDATES MEM.SAV.FE! +L1   `*  70 2 2A} 0.* 1 y0 0)INSERT BOTH DISKS, TYPE RETURN^, 1 y038逍 N, 1L! ,B}C, t*  Lx+, 0 ^, 1 y0 , ,0,0 ,L+ ,I0 ,Vǭ0C}Ξ, 0 }, 1 y0C,ШC, 0K'!" H H 'h h Lx+!EF 5L1L!D,I,HhD}` NOT ENOUGH ROOMINSERT SOURCE DISK,TYPE RETURNINSERT DESTINATION DISK,TYPE RETURNE}`  `8 rL1`-* 1P* 1 y0Y`hhL!NAME OF FILE TO MOVE?- 0 0|DL% <.F},^ 1 70 0 .@L# .BJ 1  DEHIB V L1 ,} 1 70,L.  G}JB|,#P#DE 1 HI BDEHHII 1 B 1 ,^ 1 70,0La- B V,#PH},^ 1 70 0L#L!-* 1P* 1 y0Yj383}mm ݭI}}`8}``|* ? ɛ,`|:-)| / 1L!`DESTINATION CANT BE DOJ}S.SYS0 0H{ 24Δ 28/L!/) 2 Π 2 0 ξK}hAΞB,0 J 1 BDEHI,HÝDE 1HIHIDELSAVE-GIVE L}FILE,START,END(,INIT,RUN)O S0 1`BDEPHI V` S0H 1 L!M}0 0 1L~0`PLEASE TYPE 1 LETTER,0`hhL! 70 1L0L<1 ,;ɛ7,"ɛ:ݦ1ݥN}A"D|ݤD|ȩ:|ȩ|ɛ,,(/+.ީ1 1,ɛ`轤{NAMEO} TOO LONG B VL!` L1I H1EΝDL1|mDiE` V0`8d/8 i:222 1 LP}!ERROR- 138ɛ+,' 20*.. өr2 1``2TOO MANY DIGITSINVALID HEXAQ}DECIMAL PARAMETER800 0 8 00`,0'D800 H,ɛh`2L1NEED D1 THRU D8uR} ECIMAL PARAMETER800 0 8 00`,0'D800 H,ɛh`2L1NEED D1 THRU D8u12 4 1 5 0 10 70 2 12 13227E27HAtari* System Reference manual(c) 1987 By Bob DuHamelT}Bob Duhamel6915 Casselberry WaySan Diego, CA 92119*Atari is a registered trademark of Atari CorU}p.This manual contains highly technical information. Such information is provided for those who know how to use it. ToV} understand the advanced information you are expected to know 6502 assembly language. If you are new to programming, concentW}rate on the parts which discuss BASIC commands. Information important to BASIC programmers is in 27Gbold27H print.AddresX}ses are usually given in both hexadecimal and decimal numbers. The operating system equate names are given in capital letterY}s with the address following in brackets. The decimal address is in parenthsis within the brackets. For example: DOSVEC [Z}$000A,2 (10)] name hex decThe ",2" after the hexadecimal number means that this address requires two bytes to hol[}d its' information. Any address called a "vector" uses two bytes whether noted or not.Control registers and some other byt\}es of memory are shown in the following formatRegister format 7 6 5 4 3 2 1 0 ----------------- | ]} | ----------------- 1 6 3 1 8 4 2 1 2 4 2 6 8The numbers on top are the bit numbers. Bit 7 i^}s the Most Significant Bit (MSB) and bit 0 is the Least Significant bit (LSB). The numbers on the bottom are the bit weights_}. These are useful when changing memory with decimal numbers, as you would in BASIC. For example, to set bit 4 of a registe`}r to 1, without changing any other bits you would add 16 to the decimal number already in the register. To reset the same bia}t to 0, you would subtract 16 from the number in the register. This is exactly what the command GRAPHICS 8+16 does. It setsb} bits 3 and 4 of a graphics mode control register.MSB and LSB may also mean Most Significant Byte or Least Significant Bytec}, depending on context.CONTENTS 1 THE CENTRAL INPUT/OUTPUT UTILITY, (CIO) 2 THE DISK OPERATING SYSTEM (D:) 3d} USING THE DOS 2 UTILITIES (DUP.SYS) 4 THE CASSETTE HANDLER (C:) 5 THE KEYBOARD HANDLER (K:) 6 PRINTER HANDLERe} (P:) 7 SCREEN EDITOR (E:) 8 THE DISPLAY HANDLER (S:) 9 THE RESIDENT DISK HANDLER10 SYSTEM INTERRUPTS11 Tf}HE FLOATING POINT ARITHMETIC PACKAGE12 BOOT SOFTWARE FORMATS13 THE SERIAL INPUT/OUTPUT INTERFACE (SIO)14 THE HARDg}WARE CHIPS15 DISPLAY LISTS16 PLAYER AND MISSILE (PM) GRAPHICS17 SOUND18 THE JOYSTICK PORTS19 MISC20 Th}HE XL AND XE MODELSLAY LISTS16 PLAYER AND MISSILE (PM) GRAPHICS17 SOUND18 THE JOYSTICK PORTS19 MISC20 T12 4 1 5 0 10 70 2 12 1321-@27E27HCHAPTER 1THE CENTRAL INPUT/OUTPUT UTILITY, (CIO)27GThe ATARI compu j}ter uses a very easy-to-use input and output system called the Central Input/Output utility, or CIO. Nearly all input or out k}put passes through this utility.CIO uses eight "channels" as paths for I/O. There are not really separate channels for I/O l} but the computer acts as if there were. 27HEach channel is controlled by a 16 byte block of memory called an Input/Output m}Control Block or IOCB. The channels are used by putting the proper numbers in the proper IOCB bytes then jumping to the CIO n}routine. 27GIn BASIC, complete I/O operations can be as easy as typing a command such as LPRINT. In this case BASIC does a o}ll the work for you.THE CIO CHANNELSThere are eight CIO channels, numbered from 0 to 7. In BASIC some channels are reser p}ved for BASIC's use.BASIC CIO channel assignments Channel 0 Permanently assigned to the screen editor 6 q} Used for graphics commands 7 Used for the Cassette, disk and printerChannels 6 and 7 are free to use whe r}n they are not being used by BASIC. 27HWith machine language, all of the channels are available to the programmer.THE IOC s}B STRUCTURE The IOCB for channel zero starts at address $0340 (decimal 832). This is the only address you need to know. I t}ndexing from this address is used to find all of the other bytes. Below are the names and uses of the IOCB bytes.IOCB by u}tes and uses:ADDRESS NAME EXPLANATION $0340 ICHID handler Identifier $0341 ICDNO device number (dis v}k) $0342 ICCOM command $0343 ICSTA status $0344 ICBAL buffer address (low byte) $0345 ICBAH buffe w}r address (high byte) $0346 ICPTL address of put byte $0347 ICPTH routine (used by BASIC) $0348 ICBLL b x}uffer length (low byte) $0349 ICBLH buffer length (high byte) $034A ICAX1 auxiliary information $034B ICAX2 y} - $034C ICAX3 the remaining auxiliary $034D ICAX4 bytes are rarely used $034E ICAX5 - $034F ICAX z}6 -ICHIDWhen a channel is open, the handler I.D. contains an index to the handler table. The handler table (to be di {}scussed later) holds the address of the device handling routines. When the channel is closed ICHID contains $FF.ICDNOThe |} device number is used to distinguish between multiple devices with the same name, such as disk drives.ICCOMThe command b }}yte tells CIO what operation to perform.CIO command codes HEX DEC +Open $03 3 ~} +close $0C 12 get $07 7 put $09 11 input $05 5 print } $09 9 +status request $0D 13 +*special >$0D >13 + command may be made to a clos }ed channel * device specific commandsICSTAThe status byte contains an error code if something goes wrong. If bit 7 i }s 0 there have been no errors.ICBAL and ICBAHBefore a channel is opened, the buffer address bytes are set point to the bl }ock of memory which contains the name of the device the channel is to be opened to. Before actual input or output these byte }s are set to point to the block of memory where the I/O data is stored or is to be stored.ICPTL and ICPTHThe put routine }pointer is set by CIO to point to the handlers' put-byte routine. When the channel is closed the pointer points to the IOCB- }closed routine. This pointer is only used by BASIC.ICBLL and ICBLHThe buffer length bytes show the number of bytes in th }e block of memory used to store the input or output data. (See ICBAL and ICBAH.) If the amount of data read during an input } operation is less than the length of the buffer, the number of bytes actually read will be put in ICBLL and ICBLH by CIO.I }CAX1 through ICAX6The auxiliary information bytes are used to give CIO or the device any special information needed.D:C }HAP1.1rough ICAX6The auxiliary information bytes are used to give CIO or the device any special information needed.D:C 27GOPENNING A CIO CHANNELBefore using a CIO channel it must be assigned to an I/O device. 27HIn machine language you sta}rt by putting the channel number in the four high bits of the 6502 X register (X = $30 for channel three). Next you place th}e necessary codes (parameters) into IOCB 0 indexed by X. The X register will cause the numbers to be offset in memory by 16 }times the channel number. This puts the numbers into the correct IOCB instead of IOCB 0. Below are the parameters used to o}pen a channel.Channel-open parameters: ICCOM open code ICBAL address of device name ICBAH in memory ICAX}1 direction code ICAX2 zeroThe direction code byte in ICAX1 takes on the following format:ICAX1 format for open}ing a channel 7 6 5 4 3 2 1 0 ----------------- ICAX1 | W R | ---------}-------- 8 4 2 1 W 1 = open for output (write) R 1 = open for input (read)ICAX1 may have the fo}llowing data27GCIO direction codes HEX DEC operation $04 4 input $08 8 output $0C} 12 input and output (cannot change the length of a disk file)27HICBAL and ICBAH point to the device }name stored in memory. The device and file name must be followed by 0 or $9B (decimal 155).Once the parameters are set, ju}mping (JSR) to the CIO vector(CIOV) at address $E456 (58454) will cause the channel to be opened. In the following exampl}e a basic knowledge of assembly language is assumed.Routine to open channel 1 to the keyboard: ICHID = $0340 } ICCOM = ICHID+2 ICAX1 = ICHID+10 ICAX2 = ICHID+11 IOCB1 = $10 channel in four high bits CI}OV = $E456 OPEN = $03 OREAD = $04 ;open for input ERROR = (address of error handling routine) ;} START LDX IOCB1 LDA OPEN STA ICCOM,X LDA NAME STA ICBAH,X } LDA OREAD STA ICAX1,X LDA #0 STA ICAX2,X JSR CIOV BPL OK JMP ERROR ; N}AME .BYTE "K:",$9B OK (program continues here)27GTo open a CIO channel in BASIC the OPEN command is used. BASIC }OPEN command format: OPEN #channel,aux1,aux2,device:file name aux1 = direction code aux2 = special codeTo open} channel 1 to the keyboard in BASIC Type: OPEN #1,4,0,"K:"The third parameter, aux2, is a rarely used special paramete}r. One use is to keep the screen from erasing when changing graphics modes.The fourth parameter is the device to open the }channel to. It may be either a string in quotes or a string variable.CIO device names C cassette recorder *}D disk drive E screen editor K Keyboard P printer *R RS 232 I/O port S screen handler } * Uses a non-resident handler loaded by the device at power-up.The device name must usually be followed by a colo}n. With the disk drive a file name is expected after the device name. The screen handler is used for graphics. The screen }editor uses both the keyboard handler and the screen handler to work between the keyboard and screen.D:CHAP1.2The screen r27GUSING AN OPEN CHANNELOnce a channel is opened to a device you have several options:INPUT:27H (ICCOM = $05)27GThe} computer reads data from the device until a carriage-return is read (decimal number 155, hex $9B) or the end of the file (EO}F) is reached. A carriage return is also known as an End-Of-Line or EOL. 27HThe IOCB input parameters are:IOCB input pa}rameters: ICCOM get record code ICBAL address of buffer to ICBAH store the data in ICBLL length of the data} ICALH bufferThe following routine demonstrates the input command in assembly language. Some of the equates are in th}e channel openning example above.Input routine: GETREC = $05 BUFF = (address to store data at) }BUFLEN = (number of bytes available at storage address) : LDX IOCB1 LDA GETREC STA ICCOM,X } LDA < BUFF STA ICBAL,X LDA > BUFF STA ICBAH,X LDA < BUFLEN STA ICBLL,X L}DA > BUFLEN STA ICBLH,X JSR CIOV BPL OK2 JMP ERROR : OK2 (continues if no errors)}If the data retrieved is shorter than the prepared buffer, the number of bytes actually read will be put into ICBLL and ICBL}H.27GIn BASIC, the INPUT command is used.BASIC INPUT command format: INPUT #channel,string variableor INPUT #ch}annel,arithmetic variableFor example: INPUT #1,IN$The above commands will cause the data from the device to be put int}o the specified buffer (IN$ in the BASIC example) until an EOL is reached. If the INPUT statement is used again, without clo}sing the channel, the computer will get more data from the device until another EOL is read or the end of the file is reached}. The new data will write over the old data in the input string or buffer. If an arithmetic variable is used, only numbers }can be input.PRINT: 27H(ICCOM = $09)In assembly language the print command is identical to the input command. The only} difference is that the PUTREC code ($09) is stored in ICCOM. Of course the buffer bytes of the IOCB then specify the block }of memory to be output from rather than input to. With the print command, EOLs within the string or buffer are ignored but a}n EOL is placed at the end of the data when sent to the device.27GIn BASIC, the PRINT command is used like INPUT except yo}u want to use a semicolon instead of a comma to separate parameters. For example: PRINT #1;OUT$or PRINT #1;"HELLO"I}f you use a comma, ten space characters will be sent before the string.If the print command is used again, without closing }the channel, the new data will be appended to the end of the data previously sent. Old data will not be written over.GET:} 27H(ICCOM = $07)27GIn BASIC this command inputs a single byte of data from the device. EOLs are ignored. In BASIC, GE}T is used like INPUT except an arithmetic variable must be used. For example: GET #1,INIf the get command is used again }the next byte from the device will be read. If the end of a file is reached an error will occur.There is no command in BAS}IC to input an entire file without stopping at each EOL. If you wish to ignore EOLs while reading a file to a string, you mu}st use the GET command. Each byte of data is then put into the string by the program.EXAMPLE: 10 OPEN #1,4,0,"D:TEST" 2}0 TRAP 60:REM GOES TO LINE 60 WHEN END OF FILE ERROR OCCURS 30 GET #1,IN 40 IN$(LEN(IN$)+1)=CHR$(IN) 50 GOTO 30 60 CLOSE }#127HIn assembly language, the get command can be used to get any number of bytes from the device. It works just as INPU}T does except EOLs are ignored.IOCB get-byte parameters: ICCOM get-character (single byte) code ICBAL \ ICBAH }same as in input ICBLL ICBAH /Other than the ICCOM code (GETCHR = $07) this command is identical to the input command.}27GPUT: 27H(ICCOM = $0B)27GIn BASIC, PUT is the opposite of GET. It outputs a single byte from a variable to the devi}ce. PUT is used the same as GET. For example: PUT #1,OUT27HIn assembly language, the command byte of the IOCB is load}ed with the put-character code (PUTCHR = $0B). Otherwise the PUT command is identical to GET.27GCLOSING A CHANNELClosin}g a channel frees it for use by another device or for changing parameters. 27HIn assembly language the close code is put in}to the command byte of the IOCB then the CIOV call is made.IOCB close command: CLOSE = $0C : LDX IOCB}1 LDA CLOSE STA ICCOM,X JSR CIOV27GIn BASIC, use the CLOSE command followed by the channel number. }CLOSE #1With the disk drive, the file name is not put into the directory until the channel is closed.27HTHE DEVICE TABLE}CIO uses a jump table located at $031A (794). When a CIO call is made, CIO searches the table for the one-byte device name}. The two bytes following the device name contain the address of the device handler's vector table. CIO searches the device} table from the end, $033D (829) to the beginning. This way, if a custom handler has ben substituted for a resident handler,} the custom handler will be found first. (custom handlers cannot be inserted directly in the place of resident handlers in t}he device table.)Each handler has its' own vector table. This vector table is 16 bytes long. The two-byte vectors point t}o the various handler routines. The vectors are stored in the vector table in the following order:Handler vector table o}rder open close get byte put byte get stat special JMP init code (3 bytes)The open rout}ine should validate the ICAX parameters and check for illegal commands.The close routine should send any remaining data in }the buffer to the device, mark the End-Of-File and update any directories, etc.The get byte routine should get a byte from }the device or the handler buffer and put it in the 6502 A register. Handlers with long timouts must monitor the break key fl}ag and put a $80 in the 6502 Y register if the [BREAK] key is pressed.The put byte routine should send the byte in the 6502} A register to the device or handler buffer. If the buffer fills, it should be sent to the device. BASIC can call the put b}yte routine without using CIO.The get status routine may get 4 bytes of status information from the device and put them in }DVSTAT [$02EA] to DVSTAT+3.For special commands the handler must examine the command byte and find the proper routine entry} point.In all cases the status (error code) of the operation should be put in the 6502 Y register.To be compatible with a}ll versions of the operating system, the handler must redirect DOSINI [$000C,2 (12)] for initialization upon reset. This ini}tialization must restore the vectors in the handler vector table and jump to the origional DOSINI vector.27GSPECIAL COMMAN}DSSome devices have special CIO commands. These are known as device specific commands. In assembly language these command}s are executed just as any other CIO command is. In BASIC the XIO command is used. An example of the XIO command is: XIO} command code #channel,aux1,aux2,device:file nameTo open a channel with the XIO command instead of the OPEN command use: }XIO 3 #1,4,0,"K:"Note that the above command is identical to the OPEN command except "XIO 3" is used instead of "OPEN". 2}7HAlso note that $03 is the IOCB open code for ICCOM. 575Useful database variables and OS equatesDOSINI $000C,2 } (12): initialization vectorBRKKEY $0011 (17): break key flagICHID $0340 (832): start of IOCBsICDNO $034}1 (833):ICCOM $0342 (834):ICSTA $0343 (835):ICBAL $0344 (836):ICBAH $0345 (837):I}CPTL $0346 (838):ICPTH $0347 (839):ICBLL $0348 (840):ICBLH $0349 (841):ICAX1 $034A } (842):ICAX2 $034B (843):HATABS $031A,16 (794): device handler tableCIOV $E456 (58454): CIO entry vect}or842):ICAX2 $034B (843):HATABS $031A,16 (794): device handler tableCIOV $E456 (58454): CIO entry vect12 4 1 5 0 10 70 2 12 1322-@27E27HCHAPTER 2THE DISK OPERATING SYSTEM (D:)27GThe disk operating syste}m program (DOS) is also called the file management system (FMS). DOS is not a permanent part of the computer, it is loaded i}n upon power-up if a disk drive is attached to the computer.When the computer is turned on, one of the first things it does} is send a request to the disk drive to load DOS into the computer. This startup operation is called booting. The word boot} is short for bootstrapping -- the start-up process of early computers. The term comes from "lifting one's self by one's boo}t straps".27HAnytime the disk boots, the computer tries to read a program starting at sector 1 and continuing in sequence.} If the disk has DOS on it, the first three sectors, called the boot record, have a program which loads the DOS.SYS file. }27GIf there is no DOS.SYS file on the disk the computer will display: -------------------- | BOOT ERROR | | BO}OT ERROR | | BOOT ERROR | | BOOT ERROR | | BOOT ERROR | | BOOT ERROR | | (etc.}) | | | | | -------------------- 27HWhen a disk is formatted, the dri}ve read/write head passes over the entire disk and puts magnetic marks on it. These marks divide the disk into 32 concentric} tracks. With DOS 2.0 each track is divided into 18 sectors, each holding 128 bytes of data. With DOS 2.5 there are 32 sect}ors per track giving a total of 1,024 sectors.Each sector on the disk is marked with a reference number from 1 to 720. Unf}ortunately, the writers of DOS 2.0 didn't know this so they wrote the DOS to use sectors numbered from 0 to 719. As a result}, DOS 2.0 cannot access sector 720. The designers of the disk drive were the guilty party in this case. It is normal to num}ber from 0 in computers. With DOS 2.5, sectors 720 - 1,024 can be accessed normally.Sector 720 can be accessed using the }computer's resident disk handler. Some software writers use sector 720 to hide special information to make their programs di}fficult to copy.DOS 2 SECTOR ASSIGNMENTSSectors 1 through 3 are called the boot record. They contain a program which lo}ads the DOS.SYS file into memory. Sector 360 is called the Volume Table of Contents or VTOC. The main purpose of the VTOC }is to keep track of what sectors are occupied. Bytes 3 and 4 of the VTOC tell how many sectors are available. Starting at b}yte 10 is the Volume Bit Map. Each byte in the VBM tells the status of eight sectors. If a bit is a 1 the sector is availab}le. If a bit is a 0 the sector is occupied.Sectors 361 through 368 contain the disk directory. Each directory sector hold}s eight file names. The first byte of a file name is called the flag byte. It tells the status of that file.Directory f}lag byte. 7 6 5 4 3 2 1 0 ----------------- | flag byte | -----------------Bits: 7 1 = file de}leted 6 1 = file in use 5 1 = file locked 0 1 = open for outputThe next two bytes tell how many} sectors are in the file. The two bytes after them tell the starting sector of the file. The last 11 bytes contain the file} name.Sector 720 cannot be accessed with DOS 2.0.The boot record, VTOC, directory and sector 720 use 13 sectors. This le}aves 707 sectors for storing files with DOS 2.0.Each file sector has 125 bytes of data. The last three bytes tell how many} bytes of the sector are used, what directory entry the sector belongs to and which sector is next in the file.File secto}r structure 7 6 5 4 3 2 1 0 ----------------- | data | byte 0 - - - - | byt}es | byte 124 ----------------- | Dir. No. |hi | byte 125 ----------------- |forward pointer| byte 1}26 ----------------- |S| byte count | byte 127 ----------------- hi = high 2 bits of forward pointer } S = Short sector flag. 1 = short sector (End Of File)If the directory number does not match the order of the file name} in the directory, an error 167 (file number mismatch) will occur.As a file is written to an empty disk it is put in conse}cutive sectors, 125 bytes at a time. After the file is written, the VTOC and directory are updated. When new files are writ}ten they also use consecutive sectors.When a file is deleted the status bit of the directory is changed to show that the fi }le has been deleted. DOS then tracks the file, sector by sector, to find what sectors are used. Finally the VTOC is updated } to show that the deleted file's sectors are available for new files. The file is not erased from the disk; only the VTOC an }d directory are changed.When a file is deleted, an "island" of free sectors may be left on the disk. When a new file is th }en written to the disk it will first use these new free sectors. When the island is used up, DOS will skip over the occupied } sectors to the next free sector. This is the reason for the sector link. A file can end up with it's sectors scattered all} over a disk. It can be complicated but it's efficient.D:CHAP2.1link. A file can end up with it's sectors scattered allEDISK FILE STRUCTURE27HThe first few bytes of a file may tell DOS or another program what kind of file it is. These infor}mation bytes are called a header.A text file is any file which has no header. A listed BASIC program is a type of text fil}e. A letter from a word processor is another.A binary load file is a file intended to load to a specific address in memory}. The first two bytes of a binary load file are decimal 255. The next two bytes hold the address at which the file is to lo}ad. The last two header bytes tell the ending address for the file. If the file is a program and is to run automatically, t}he initialization and run address are appended to the end of the file.binary load file header Decimal Hexa}decimal 255 identifier FF 255 FF 0 start 00 7 07} 15 end FF 8 08The above file would load at address $0700 (1792 decimal) and end} at address $08FF (2063). If a binary load file has initialization and run address appended to it they take on the following} format:Init and run tailer CHR Decimal Hexadecimalinit address format [b] 226 identifier E2} | 2 02 [c] 227 E3 | 2 02 n address nn } n nnrun address format [diamond] 224 identifier E0 | 2 02 [a] } 225 E1 | 2 02 n address nn n nn [ ]=inve}rse videoA program which doesn't need special initialization can be run at the init address. Otherwise, an RTS instructio}n is expected at the end of the initialization section. The computer will then jump to the run address if specified.INSID}E THE COMPUTERDOS uses the computer's CIO utility. When a DOS disk is booted a non-resident handler is loaded into memory.} A new handler name, D, is then added to the handler table. When CIO is called with a device name of D: or Dn:, CIO will se }arch the handler table for that device name. If the 'D' is found, the next two bytes in the table point to the DOS entry add!}ress.27GDOS FILE NAME CONVENTIONSDOS is unique among CIO handlers in that it requires an eight character file name to fo"}llow the device name. This file name may be followed by a period and then a three character extender.EXAMPLES: D:TEST, D2#}:FIREMAN, D:VENTURE.EXE, D:CHAPTER.001The D2: is used for drive number two if present.The file name must use upper-case $}letters or numbers. The first character must always be a letter. WILD CARDSThe characters * and ? may be used as wild c%}ards. * means any combination of characters and ? means any single character.EXAMPLES: D:P* any file beginning &}with P and without an extender D:*.EXE any file with the extender .EXE D'}:*.* any file. D:F?REMAN one unknown character, FIREMAN or FOREMAN will mat(}chWild cards can only be used to load, delete, lock and unlock files. When loading a file using wild cards, only the firs)}t matching file will be loaded.When renaming a file, both the new and old names are expected after the device name.EXAMPL*}E: D:OLDNAME.BAS,NEWNAME.BASTo format a disk, only the device name (D: or Dn:) is needed.USING DOSWhen a CIO channel i+}s opened to the disk drive it must actually be opened to a specific file on the disk. The device name in the open command mu,}st be followed by a file name.When a channel is opened to the disk, two special parameters may be used in ICAX1.27HICAX-}1 for disk open: 7 6 5 4 3 2 1 0 ----------------- | W R D A| -----------------.} D 1 = open to read the directory instead of a file A 1 = append data to the end of the fileThis gives the following /}extra ICAX1 options.27GDisk specific ICAX1 options: HEX DEC $06 6 open to read director0}y $09 9 output, append to the end of an existing fileREADING THE DIRECTORYWh1}en the directory is read, each file name is treated as if it were followed by an EOL. A loop must be used to read all of the2} file names in the directory. The last entry read is the free sector count. After it is read, another read operation will r3}esult in an End-Of-File error.The disk drive has a number of device specific commands other than the regular CIO commands. 4} From BASIC the XIO command is used to access these commands. 27HThe XIO command allows you to directly load the IOCBs from5} BASIC. Each parameter of the XIO command places values in certain bytes of an IOCB.27GXIO command format: XIO comma6}nd channel,aux1,aux2,device:file nameNote that the parameters resemble the BASIC OPEN command. The BASIC OPEN command is 7}identical to it's equivalent XIO command.XIO commands specific to the disk drive.RENAME XIO $20 (32)DELETE XI8}O $21 (33)LOCK XIO $23 (35)UNLOCK XIO $24 (36)POINT XIO $25 (37)NOTE XIO $26 (38)FORMAT 9} XIO $FE (254)EXAMPLES: XIO 33 #1,0,0,"D:JUNK" = delete file named D:JUNK XIO 32 #1,0,0,"D:OLD,NEW" = change name o:}f D:OLD to D:NEWNOTE and POINT can also be used directly from BASIC. NOTE finds the current position of the read/write he;}ad on the disk. POINT moves the read/write head to the desired position.USING NOTE AND POINTThe command format for NOTE <}and POINT is as follows: NOTE \ channel,sector,byte POINT/EXAMPLE: NOTE #1,SECT,BYTEBASIC requires the se=}ctor and byte parameters in both commands to be variables. Fixed numbers cannot be used. If you try to do a POINT to a sect>}or outside the file the channel is open to, a point error will occur. Care may need to be taken to be sure the file being ac?}cessed is in contiguous sectors on the disk. If it is not, it will be difficult to know where to do points to.One use of N@}OTE is to use the command immediately after opening a channel to a disk file. After the NOTE command, the parameter variableA}s contain the coordinates of the first byte of the file. They can then be used as a reference for the POINT command.27HInB} assembly language, ICAX3 and ICAX4 are used for the sector number (lsb,msb). ICAX5 is used for the byte number.STATUS REQC}UESTIf the status request command is used, one of the following values will be found in ICSTA and the 6502 Y register. D} HEX DEC $01 1 OK $A7 167 file locked $AA 170 file not found {12 4 1 5 0 10 70 2 12 1323-@27E27HCHAPTER 3USING THE DOS 2 UTILITIES (DUP.SYS)If you boot a DOS disk !F}with no cartridge in the slot or with BASIC disabled (by holding the OPTION key), DOS will try to load the file named DUP.SYS!G}. This is the disk utility file. When using BASIC, typing DOS [RETURN] will load the DUP.SYS file. When the utilities are !H}loaded the menu will appear on the screen.THE DOS UTILITIES MENUDISK OPERATING SYSTEM II VERSION 2.0SCOPYRIGHT 1980 ATA!I}RIA. DISK DIRECTORY I. FORMAT DISKB. RUN CARTRIDGE J. DUPLICATE DISKC. COPY FILE K. BINARY SAVED. DELETE FILE(S!J}) L. BINARY LOADE. RENAME FILE M. RUN AT ADDRESSF. LOCK FILE N. CREATE MEM.SAVG. UNLOCK FILE O. DUPLICATE D!K}ISKH. WRITE DOS FILES SELECT ITEM OR [RETURN] FOR MENU[A] DIRECTORYAfter pressing [A] [RETURN] you will get the promp!L}t: DIRECTORY--SEARCH SPEC,LIST FILE?If you want to see the entire directory just press [RETURN] again. If you wish, you !M}may type in a specific file name (D: is optional) or wild cards to search for. If you specify a search spec only matching fi!N}les will be displayed.If you want, you can have the directory sent to another device. To do this type a comma and the devi!O}ce name. For example, if you type ,P: the directory will be sent to the printer.[B] RUN CARTRIDGEIf a cartridge was inse!P}rted or BASIC was not disabled when the computer was turned on, [B] [RETURN] will run that cartridge or BASIC.[C] COPY FIL!Q}EThis option will copy a file to another part of the same disk (with a different file name) or copy from one disk drive to !R}another. When you press [C] [RETURN] you will be given the prompt: COPY--FROM,TOType the devices and file names separate!S}d by a comma.EXAMPLES:FOREMAN,FIREMANorD1:TEST,D2:TESTThe first example will copy to the same disk. The seco!T}nd example will copy from disk drive one to disk drive two.If you want to have the first file appended to the end of the se!U}cond file type /A after the file names.EXAMPLE:RUNMENU.EXE,AUTORUN.SYS/AIf the files are binary load files, this wi!V}ll cause both files to be saved as one file. When the load command is used they will both be loaded and run.[D] DELETE FIL!W}E(S)After pressing [D] [RETURN] you will get the prompt: DELETE FILE SPECAfter typing the file name you will be asked t!X}o confirm the file to delete. DELETE FILE SPEC DELETE-D1:JUNK ARE YOU SURE?Press [Y] if the correct file is displayed. !Y}If you use wild cards you will be asked to confirm each matching file.[E] RENAMEUpon typing [E] [RETURN] you will be giv!Z}en the prompt: RENAME-GIVE OLD NAME,NEWType the file name you want to change and the new name separated by a comma.EX![}AMPLE:COLT,HORSEWARNING! Do not rename a file to a name which already exists on the disk. You will end up with a dupl!\}icate file name and will not be able to access one of them. Attempting to rename or delete one of them will rename or delete!]} both. The only way to fix a duplicate file name is with a sector editor or other special utility.[F] LOCK FILEA locked !^}file cannot be written to, renamed or deleted. To lock a file type [F] [RETURN]. You will get the prompt: WHAT FILE TO LO!_}CK?Type the file name you want to lock. Wild cards will cause all matching files to be locked.[G] UNLOCK FILEUsed the !`}same as lock.[H] WRITE DOS FILESThis option will write the DOS.SYS and DUP.SYS files to a formatted disk. When you type !a}[H] [RETURN] you will receive the prompt: DRIVE TO WRITE DOS FILES TO?Type the number of the drive. If the drive contain!b}s a formatted disk the dos files will be written to it.[I] FORMAT DISKThis option formats a new disk or erases a disk wi!c}th files on it. Typing [I] [RETURN] will get you the prompt: WHICH DRIVE TO FORMATBe sure you have the correct disk in t!d}he proper drive then type the drive number. It is impossible to recover files on a disk formatted by accident.While the di!e}sk is being formatted the drive will check to be sure the disk is formatted correctly. If not, the drive attempt to format t!f}he disk again. If the disk is defective the drive will not finish the formatting process.[J] DUPLICATE DISKThis option w!g}ill copy an entire disk except for sectors listed as free in the VTOC. Some programs are copy-proofed by changing the VTOC t!q}B%DOS SYSB*)DUP SYSBSCHAP0 B!iCHAP1 BCHAP1 1 BACHAP1 2 B*CHAP2 B6CHAP2 1 BGECHAP3 BCHAP4 B(CHAP5 BCHAP6 BCHAP7 B4CHAP8 B2CHAP8 1 B#PCHAP8 2 B,sCHAP8 3 B!CHAP9 &CHAP10 'CHAP10 1 : CHAP11 4GCHAP12 3{CHAP13 CHAP14 :CHAP15 CHAP15 1 o show that some occupied sectors are empty. For such disks, a program which copies the entire disk is needed.When you pre!r}ss [J] [RETURN] you will be given the prompt: DUP DISK--SOURCE,DEST DRIVES?If you are using only one disk drive, type 1,1!s}. If you have only one drive you will be told when to swap disks.[K] BINARY SAVEThis option saves a block of memory as a!t} binary load file. When you type [K] [RETURN] you will be given the prompt: SAVE-GIVE FILE,START,END(,INIT,RUN)Type the !u}desired file name and a comma. Now type the start and end addresses of the memory block to be saved, in hexadecimal numbers,!v} separated by commas. If the file is a program which is to automatically run when loaded, give the initialization address, i!w}f needed, then the run address.EXAMPLE:CHASE.EXE,0700,09FF,,0700This will save the block of memory from address 07!x}00 to 09FF. The program is not initialized before running so there is no address typed after the third comma. When the prog!y}ram is loaded the computer will jump to address 0700, as specified in the last parameter, to run the program.[L] BINARY LOA!z}DTo load a binary file type [L] [RETURN]. You will get the Prompt: LOAD FROM WHAT FILE?Type the file name and the file !{}will be loaded. If wild cards are used, only the first matching file will be loaded.[M] RUN AT ADDRESSTyping [M] [RETURN!|}] will get the prompt: RUN FROM WHAT ADDRESS?Type the hexadecimal address of the program you want to run.[N] CREATE MEM!}}.SAVA MEM.SAV file is used by BASIC and some other programs to save the part of memory which the DUP.SYS file loads into. !~}If there is no MEM.SAV file on the disk when you go to the DOS utilities, you will loose that part of memory. With BASIC you!} will loose your program.When you type [N] [RETURN] you will get the prompt: TYPE Y TO CREATE MEM.SAVTyping [Y] [RETURN!}] will create a MEM.SAV file on the disk in drive one.[O] DUPLICATE FILEThis option is used to copy a file from one disk !}to another, using only one disk drive. When you type [O] [RETURN] you will get the prompt: NAME OF FILE TO MOVE?If you !}use wild cards you will be asked to swap disks for each matching file.DOS 2.5 also has option:[P] FORMAT SINGLEDOS 2.5!} normally formats disks to use "enhanced" density. This option will format a disk in single density for use with the 810 dri!}ve.DOS 2.5 also has some special utilities on the master disk. Use the binary load option to run them.RAMDISK.SYSThis !}program will cause the extra bank of memory in the 130XE to act like a disk drive (called D8:). If this program is on the di!}sk it will automatically run. It need not be renamed to AUTORUN.SYS.COPY32.COMCopies DOS 3 files to DOS 2.DISKFIX.COM!}Can make certain "repairs" to a disk, such as restoring deleted files.SETUP.COMUsed to change the default configuration !}of DOS.AUTORUN.SYS (DOS 2.0 and 2.5)This program is needed to operate the RS-232 ports on the 850 interface. If you don'!}t want this program to automatically load when you boot with the master disk, rename the file to RS232.SPECIAL DOS INFORMAT!}IONWhen DOS is in memory, changes can be made to the DOS program. These changes can be made by poking the changes into mem!}ory. If you want to make the changes permanent, you can type DOS [RETURN] to load the utilities. From the utilities menu yo!}u can use the write DOS files option to save the changes on disk. Some of the useful changes you can make follow. POKE 19!}13,80This turns off the write verify and speeds up disk writing. POKE 1913,87This turns write verify on POKE 5903,4!}2 POKE 5904,46 POKE 5905,82 POKE 5906,85 POKE 5907,78 POKE 5908,155This causes any binary file with the extender .RUN !}to be loaded automatically when the computer is turned on. POKE 5903,65 POKE 5904,85 POKE 5905,84 POKE 5906,79 POKE 59!}07,82 POKE 5908,85This returns the DOS to normal, Automatically loading files named AUTORUN.SYS. DOS 2.0 !}DOS 2.5 POKE 3772,255 POKE 3818,64 POKE 3774,64 POKE 3822,123 POKE 3778,123This will cau!}se DOS to accept lower-case as well as upper-case letters in file names. It will also now accept @,[,\,],^ and _ . !} POKE 3772,223 POKE 3818,65 POKE 3774,65 POKE 3822,91 POKE 3778,91 This will change DOS back to !}normal, accepting only upper-case letters and numbers.4,65 POKE 3822,91 POKE 3778,91 This will change DOS back to 712 4 1 5 0 10 70 2 12 1324-@27E27HCHAPTER 4THE CASSETTE HANDLER (C:)27HThe cassette handler sends da%}ta to the cassette recorder in blocks of 128 bytes each. The blocks are sent in the following format:Cassette record for%}mat ----------------- |0 1 0 1 0 1 0 1| speed measurement bytes ----------------- |%}0 1 0 1 0 1 0 1| ----------------- | control byte | ----------------- | 128 %} | = data = | bytes | ----------------- | checksum | handled %}by SIO -----------------The control byte may have one of the following values. $FC (252) record is full.%} $FA (250) partly full, next record is EOF. $FE (254) EOF record, data section is all zeroes.The cassette handle%}r has two modes of operation. The first mode uses only a short gap between records. It is called the no IRG (interrecord ga%}ps) mode. The second mode uses longer gaps between records and is called the IRG mode. In the IRG mode the computer may sto%}p the cassette recorder between records for processing data.When a channel is opened to the cassette recorder, bit 7 of ICA%}UX2 may be set to 1 (ICAX2 = $80 (128)). This will cause the cassette to use the no IRG mode.A cassette file starts with a%} 20 second mark tone. This tone is followed by the file records with 128 data bytes each. The final record is an End-Of-Fil%}e record.27GThe cassette is a straight-forward read/write device. There are no special functions other than those common %}to other CIO devices.27HThe cassette motor is controlled by one of the controller port control registers. If bit 3 of PAC%}TL [$D302 (54018)] is 0 then the cassette motor is on. 27GThe following BASIC commands will turn the cassette motor on and %}off.Cassette motor control. POKE 54018,PEEK(54018)-8 motor on POKE 54018,PEEK(54018)+8 motor off 57527H%}Useful data base variables and OS equatesPACTL $D302 (54018): port A control register, bit 4 %} controls cassette motoruatesPACTL $D302 (54018): port A control register, bit 4 $$12 4 1 5 0 10 70 2 12 1325-@27E27HCHAPTER 5THE KEYBOARD HANDLER (K:)27GThe keyboard is a read only d)}evice and therefore the keyboard handler has no output functions.The keyboard handler reads the keys as ATASCII codes. Eac)}h key is represented by one byte of data. Therefore, each time a key is pressed the data is treated as a byte of data just a)}s data from any other device is. The only difference is that the computer must wait for the operator to press the keys as it)} reads the data.27HWhenever a key is pressed an IRQ interrupt is generated by the keyboard reading hardware. The internal)} code (not ATASCII) for the key just pressed is then stored in CH [$02FC (764)]. The code is then compared with the prior ke)}y code in CH1 [$02F2 (754)]. If the code in CH1 is different from the code in CH, the key is accepted. The code is then con)}verted to ATASCII, and placed in the database variable ATACHR [$02FB (763)]. On XL and XE models, KEYDEF [$0079,2 (121)] poi)}nts to the key-code-to-ATASCII conversion table. (This address is used by the the screen handler in 400/800 models).If the)} code in CH1 is the same as the code in CH, the new key code will not be accepted unless the key debounce timer, KEYDEL [$02F)}1 (753)] is 0.When CIO is told to do an input operation from the keyboard, CH is checked to see if a key has been pressed. )} If CIO finds $FF (255) in CH, it waits until a key is pressed. If CH is not $FF, a key has been pressed and the ATASCII cod)}e for that key is taken from ATACHR. CH is then set to $FF.The data in CH is in the following format.Key code format:)} 7 6 5 4 3 2 1 0 ----------------- |C|S| key code | ----------------- C 1 = [CTRL] )}key is pressed S 1 = [SHIFT] key is pressedAnytime a key is pressed, CH is loaded with the key code. CH will hold the c)}ode until the computer is commanded to read the keyboard. 27GSometimes the computer will read a key which was pressed long )}ago. If you want to prevent this, load CH with $FF before reading the keyboard. (In BASIC use POKE 764,255.) This will cle)}ar out any old key pressings.Special function keys [CTRL][1] screen output start/stop [CTRL][2] BEL)}L [CTRL][3] Generates End-Of-File status [/|\] or [/] inverse video toggle [CAPS LOW)}ER] sets lower case [CTRL][CAPS] sets CTRL lock [SHIFT][CAPS] sets caps lock27HKEYBOARD REPEAT DELAY AND RA)}TE CONTROLOn the XL and XE, KRPDEL [$02D9 (729)] determines the delay before the key repeat begins. The value of this byte)} is the number of vertical blanks (1/60th second each) to delay. KEYREP [$02DA (730)] determines the repeat rate in vertical)} blanks.KEYBOARD CLICKThe keyboard click of the XL/XE is heard through the TV speaker. The click may be turned off by pu)}tting $FF in NOCLIK [$02DB (731)].NON-HANDLER, NON-CIO KEYSThe [OPTION], [SELECT] and [START] keys are read from the cons)}ole switch register, CONSOL [$D01F (53279)].The console switch register 7 6 5 4 3 2 1 0 -----)}-------------------- CONSOL |0 |0 |0 |0 |SP|OP|SE|ST| ------------------------- 8 4 2 )}1 ST 0 = [START] SE 0 = [SELECT] OP 0 = [OPTION] SP Console speaker. set to 1 during vertical blank. )} toggleing this bit operates the speaker (which is heard through the TV on XL/XE models). This bi)}t always reads 0The [HELP] key on XL and XE models is read from HELPFG, [$02DC (732)]. This address is latched and must be)} reset to zero after being read.The [HELP] key register 7 6 5 4 3 2 1 0 ----------------- HELPFG )} |C S 0 H 0 0 0 H| ----------------- 1 6 3 1 8 4 2 1 2 4 2 6 8 H 1 )}= [HELP] (bits 0 and 4) S 1 = [SHIFT] C 1 = [CONTROL] 575Useful database variables and OS equatesKEYDEF )}$0079,2 (121): key code coversion table vector (XL/XE)KRPDEL $02D9 (729): delay before key repeat (XL/XE)KEYREP $)}02DA (730): key repeat rate (XL/XE)NOCLIK $02DB (731): $FF turns off key click (XL/XE)HELPFG $02DC (732):)} [HELP] key (XL/XE)ATACHR $02FB (763): ATASCII Code for last keyCH $02FC (764): keycode, $FF if no key has )}been pressedBRKKEY $0011 (17): break key flag, 0 = break key pressedSRTIMR $022B (555): Key delay and repeat t)}imerSHFLOK $02BE (702): SHIFT/CTRL lock flag 32$00 = lower case$40 (64) = upper case lock$80 (128) = CTRL lo)}ck 5INVFLG $02B6 (694): inverse video flag, non-zero = inverseCONSOL $D01F (53279): start, select and option keysI)}RQEN $D20E (53774): IRQ interrupt enable 32bit 7 enables [BREAK]bit 6 enables other keys 5shadow registersPOKMS)}K $0010 (16): IRQEN shadowrupt enable 32bit 7 enables [BREAK]bit 6 enables other keys 5shadow registersPOKMS("12 4 1 5 0 10 70 2 12 1326-@27E27HCHAPTER 6THE PRINTER HANDLER (P:)The printer is a write only device-} so the printer handler has no input functions. The printer handler has no special functions other than the CIO functions co-}mmon to all other devices.Although many printers have special functions, the printer handler has no control over them. See-} your printer manual for information on special functions.cial functions, the printer handler has no control over them. See,;12 4 1 5 0 10 70 2 12 1327-@27E27HCHAPTER 7SCREEN EDITOR (E:)27HThe screen editor uses both the keyb1}oard handler and the screen handler to provide interactive control of the computer. In fact, the keyboard handler, the scree1}n handler and the screen editor are contained in a single section of code and are therefore very closely related.27GThe ed1}itor works with one line of characters at a time. The lines it works with are called logical lines and are up to three scree1}n lines long.27HThe screen editor inputs data from the keyboard and then prints the data on the screen. When the [RETURN]1} key is pressed, the editor inputs all of the data on the present logical line for processing by CIO.If characters are typ1}ed on the screen, and then the cursor is moved off the line, then back on the line, and new characters are typed, only the ch1}aracters to the right of the reentry point of the cursor are input when [RETURN] is pressed. However, if the cursor is moved1} off the line again, then moved back on, all characters on that logical line are input.If bit 0 of ICAX1 is 1, the editor w1}ill act as if the [RETURN] key is being held down. This bit may be changed at any time.27GEditor control codesThe scree1}n editor treats certain ATASCII codes as special control codes.Screen editor control codes KEY HEX DEC 1} FUNCTION [RETURN] $9B 155 carriage return or EOL [CLEAR] $7D 125 Clear screen,put1} cursor in 46upper left 10 [UP ARROW] $1C 28 Move cursor up one screen 46line 10 [DOWN] $1D 1} 29 down one line [LEFT] $1E 30 left one character [RIGHT] $1F 31 right one ch1}aracter [BACK S] $7E 126 Back-space operation [SET TAB] $9F 159 sets tab stop at cursor1} [CLEAR TAB] $9E 158 Clear tab stop at cursor [TAB] $7F 127 move to next tab 1}stop [SHIFT] [INSERT] $9D 157 Make space for a new line [SHIFT] [DELETE] $9C 156 1} delete the logical line at 46the cursor 10 [CTRL] [INSERT] $FF 255 make room for a character [1}CTRL] [DELETE] $FE 254 delete character at cursor [ESCAPE] $1B 27 causes next non-EOL c1}ode 46to be displayed as an ATASCII character, even if it is an editor control code 10 [CTRL] s1}creen print start/stop [1] [CTRL] $FD 253 rings bell, no effect on [2] 1} display [CTRL] creats End-Of-File status [3] 575Useful database variablesDSPFLG 1} $02FE,1 (766): if > 0 then control codes displayedd-Of-File status [3] 575Useful database variablesDSPFLG 0812 4 1 5 0 10 70 2 12 1328-@27E27HCHAPTER 8THE DISPLAY HANDLER (S:)27GThe display handler manages th5}e computer's video display. Although no data ever leaves the computer through it, the display is treated like any other CIO 5}device. Data sent to the screen may be displayed as either characters or point by point graphics. Although it is only visib5}le in the 40 column text mode, mode 0, there is a cursor on the screen in all of the text or graphics modes. Whenever a char5}acter or graphics point is put on the screen, the cursor moves just as in mode 0.The display is capable of both input and o5}utput. Information can be put on the screen with any of the CIO output commands. An input command will find whatever is on 5}the screen at the position of the cursor.27HWhen text or graphics is sent to the screen it is actually stored in an area o5}f memory called the display buffer. What you see on the screen is the computer's interpretation of the data stored there. T5}his will be explained further as each mode is covered.27GDISPLAY HANDLER SPECIAL FUNCTIONS: DRAW FILLSPECIAL5} ERROR STATUSES: $84 (132) Invalid special command. $8D (141) Cursor out of range. $91 (145) Nonexistant scre5}en mode. $93 (147) Insufficient ram for screen mode.TEXT MODE 027HIn graphics mode 0, data passes through CIO, and5} is stored in the display buffer in the following format. 7 6 5 4 3 2 1 0 ----------------- |I| Data 5} | ----------------- 11I 1 = displays character in inverse video.Bits 0 through 6 select one of the 128 characters5} in the ATASCII set.If bit seven = 1, the character is displayed in inverse video. Converting the above byte to decimal wil5}l give the BASIC ASC(x) equivalent. 10The characters displayed in the text modes are determined by tHE ATASCII character s5}et. This is a bit by bit representation of how the characters appear on the screen. The character set starts $E000 (57344) 5}in the operating system ROM. From there, for 1K of memory, each eight bytes holds a "bit map" of a particular character. Be5}low is how the letter A is stored in the character set.Letter A as represented in the C-set 7 6 5 4 3 2 1 0 5} ----------------- $E208 |0 0 0 0 0 0 0 0| ----------------- |0 0 0 1 1 0 0 0| * * -----5}------------ |0 0 1 1 1 1 0 0| * * * * ----------------- |0 1 1 0 0 1 1 0| * * * * 5} ----------------- |0 1 1 0 0 1 1 0| * * * * ----------------- |0 1 1 1 1 1 1 0| * * * * *5} * ----------------- |0 1 1 0 0 1 1 0| * * * * ----------------- $E20F |0 0 0 0 0 0 0 0| 6} -----------------XL and XE models have an international character set starting at $CC00 (55224). In this character se6}t the graphics characters are replaced by international characters.Custom characters sets may be loaded at any free address6} which is a multiple of 1,024 ($0400, or 1K). The database variable CHBAS [$02F4 (756)] stores the most significant byte (MS6}B) of the address of the active C-set. Since the LSB of the C-set address is always $00, no LSB is needed to find it.The d6}ata stored in the display buffer does not use the ATASCII code. A special code needed by the ANTIC chip is used.DISPLAY C6}ODE / ATASCII CODE CONVERSION: ATASCII display $00 - $1F ( 0 - 31) = $40 - $5F (64 - 6}95) $20 - $5F (32 - 95) = $00 - $3F ( 0 - 63) $60 - $7F (96 - 127) = unchangedThe codes for inverse video6} (the above codes with bit 7 set (= 1) or the above codes + 128 in decimal) are treated likewise.27GWhen you first turn on6} the computer, BASIC opens channel 0 to the screen editor (E:). The screen editor uses both the keyboard handler and the scr6 }een handler, in mode 0, to display characters when they are typed in.TEXT MODES 1 AND 2Graphics modes 1 and 2 offer a sp6 }lit screen configuration if desired. The split screen has four lines of mode 0 at the bottom of the screen.In mode 1 the s6 }creen holds 20 characters horizontally and 24 characters vertically. In mode 2 the characters are twice as tall so the scree6 }n holds 12 vertically.In BASIC, characters are sent to the screen with the PRINT command. Since BASIC uses channel 6 for g6 }raphics you must specify channel 6 in the command. For example: ? #6;"HELLO" 11If you use a comma in place of the semi6}colon, ten spaces will print before the "HELLO" 10You can also use the PLOT and DRAWTO commands. In this case the COLOR co6}mmand determines the character, as well as the color to be displayed.27HData passes through CIO in the following form:6} 7 6 5 4 3 2 1 0 ----------------- | C | D | ----------------- C determines the color. C 6} Default Color Shadow Color Register Register 0 green COLPF1 COLOR1 6} 1 gold COLPF0 COLOR0 2 gold COLPF0 COLOR0 3 green COLPF1 COLOR1 6} 4 red COLPF3 COLOR3 5 blue COLPF2 COLOR2 6 blue COLPF2 COLOR2 6} 7 red COLPF3 COLOR3 11D is a 5 bit ATASCII code which selects the character to be displayed. The data6}base variable CHBAS selects between upper case (CHBAS=$E0 (224)) and lower case (CHBAS=$E2 (226)). 1027GGRAPHICS MODES 3 6}THROUGH 11Modes 3 through 8 offer a split screen mode. In modes 9 through 11 special programming is required for split scr6}eens.These modes use dot by dot (pixel by pixel) graphics instead of character sets. 27HBefore explaining how graphics ar6}e sent to the screen through CIO, I will describe how the data in the display buffer is interpreted by the ANTIC chip.Mode6} 8 is the simplest of the graphics modes. Each byte of the display buffer controls eight pixels horizontally. The first 40 6}bytes of the display buffer control the first horizontal line of graphics. This makes a total of 320 pixels horizontally. I6}f one of the eight bits of a byte is a 1 then the pixel it controls is on. If a bit is a 0 then it's pixel is off. For exam6}ple, if a particular byte is equal to $9B (binary 10011011) then its' part of the screen would look like... * ** ** (106}011011)D:CHAP8.1 byte is equal to $9B (binary 10011011) then its' part of the screen would look like... * ** ** (104In reality the pixels are assigned to different color registers. A color register is a byte of memory which controls the col:}or of all pixels assigned to it. In mode 8, if a bit is = 0 it's pixel is assigned to the register called COLBK. If a bit i: }s one, it's pixel is assigned to COLPF0. See COLORS below for more information on the color registers.You may notice a clo:!}se similarity between mode 0 and mode 8. The major difference between these modes is where the dot by dot information comes :"}from. In mode 8 this information comes from the display buffer. In mode 0 the display buffer contains codes telling what ch:#}aracters to display. The actual dot by dot information comes for the character set at $E000.In mode 7 each pixel is contro:$}lled by two bits. Therefore each byte only controls four pixels. There are also only 1/4 as many pixels on the screen as in:%} mode 8. See mode 3 below for an explanation of how the each byte affects the pixels.In a graphics mode, when CIO sends a:&} byte of data to the screen handler, that byte has information for only one pixel. Do not confuse a byte which CIO sends to :'}the screen handler with the bytes in the display buffer.CIO sends data to or retrieves data from the screen in the followin:(}g forms. 7 6 5 4 3 2 1 0 ----------------- |0 0 0 0 0 0| D | Modes 3,5,7 -- D = color --------------:)}--- ----------------- |0 0 0 0 0 0 0|D| Modes 4,6,8 -- D = Color ----------------- -----------------:*} |0 0 0 0| D | Modes 9,10,11 -- D = data -----------------27GMode 3 uses a screen which is 40 pixels horiz:+}ontally and 24 vertically. Each pixel is a square the size of a mode 0 character. 27HIt requires 273 bytes of RAM where ea:,}ch byte controls 4 pixels. Each pair of bits controls which of the four color registers their pixel is assigned to.displ:-}ay buffer byte for mode 3 7 6 5 4 3 2 1 0 ----------------- | D | D | D | D | ----------------- :.}P1 P2 P3 P4 Pixel/color register assignments: D = 00 COLBK (COLOR4) 01 COLPF0 (COLOR0) 10 COL:/}PF1 (COLOR1) 11 COLPF2 (COLOR2)27GMode 4 uses a screen of 80 columns by 48 rows. Each pixel is half the size:0} of those in mode 3. 27HMode 4 requires 537 bytes of RAM where each byte controls 8 pixels. This mode is very similar to m:1}ode 8 except there are fewer but larger pixels.27GMode 5 uses a screen of 80 columns by 48 rows. The pixels are the same :2}size as in mode 4. 27HMode 5 requires 1,017 bytes of RAM where each byte controls 4 pixels in the same manner as in mode 3.:3}27GMode 6 uses a screen of 160 columns by 96 rows. 27HIt requires 2,025 bytes of RAM where each byte controls 8 pixels a:4}s in mode 4.27GMode 7 uses a screen of 160 columns by 96 rows. 27HIt requires 3,945 bytes of RAM where each byte control:5}s 4 pixels as in modes 3 and 5.Modes 8 through 11 (and 15 on XL and XE models) each require 7,900 bytes of RAM and are ver:6}y similar in display set up. The main differences between these modes is the interpretation of data in the display buffer.:7}Mode 15 (sometimes called mode 7.5) uses a screen of 160 columns by 192 rows. Each byte controls 4 pixels as in mode 7. The:8} main difference between mode 15 and its related modes is bit 0 of each instruction byte in the display list (the program whi:9}ch the ANTIC chip uses). If this bit is 0 the screen is interpreted as mode 15. If the bit is 1 the screen is interpreted a::}s modes 8 through 11.Modes 8 through 11 are set up identically in memory, including the display list. The only difference :;}is the data in the PRIOR register of the GTIA chip. The shadow register for PRIOR is GPRIOR [$026F (623)].27GMode 8 27H(:<}PRIOR = $00 - $3F (0 - 63)), 27Guses a screen of 320 columns by 192 rows. 27HEach byte controls 8 pixels as in modes 4 and:=} 6.27GMode 9 27H(PRIOR = $40 - $7F (64 - 127)) 27Guses a screen of 80 columns by 192 rows. 27HEach byte controls 2 pix:>}els. 27GThe pixels are all of the same color, controlled by COLBK. 27HEach half of a byte in the display buffer controls :?}the luminance of the assigned pixel. The format of each byte is as follows. 7 6 5 4 3 2 1 0 ----------------- :@} | data | data | ----------------- pixel 1|pixel 227GMode 10 27H(PRIOR = $80 - $BF (128 - 191), 27Gis t:A}he same as mode 9 except 9 color luminance combinations are available. 27HThe data in each half byte chooses one of the 9 c:B}olor registers for the assigned pixel.27GMode 11 27H(PRIOR = $C0 - FF (192 - 255), 27Gis the same as mode 9 except there:C} is one brightness but 16 colors. 27HThe pixel data chooses one of the 16 available colors. The luminance is that of the b:D}ackground (COLBK).27GUSING THE SCREEN HANDLER27HOPENING A CHANNEL TO THE SCREEN HANDLERWhen a channel is opened to :E}the screen handler the following actions take place: 15The area of memory to be used for the screen data is cleared.A dis:F}play list (program for the ANTIC chip) is set up for the proper graphics mode.The top-of-free-memory pointer, MEMTOP [$02E5:G},2 (741)], is set to point to the last free byte before the display list. 10Before opening a channel to the screen handler,:H} the pointer to the highest memory address needed by the program, APPMHI [$000E,2 (14)], should be properly set. This will p:I}revent the screen handler from erasing part of the program when it sets-up the screen data region.When the channel is open:J}ed, two special options can be sent with the direction parameter (ICAX1).ICAX1 for screen open 7 6 5 4 3 2 1 0:K} ----------------- | C S W R | ----------------- 1 6 3 1 8 4 2 1 2 4 2 6:L} 8 C 1 = don't clear the screen S 1 = split screen R 1 = input W 1 = outputBefore the open command, :M}the graphics mode number is placed into ICAX2.ICAX2 for screen open 7 6 5 4 3 2 1 0 -----------------:N} | : mode | ----------------- mode = $00 through $0B (0 - 11 (0 - 15 on XL/XE))27GTo open a ch:O}annel to the screen in BASIC use the GRAPHICS command.D:CHAP8.2through $0B (0 - 11 (0 - 15 on XL/XE))27GTo open a ch8DBASIC screen open format GRAPHICS modeFor Example: GRAPHICS 8This will set up a mode 8 graphics screen and open cha>Q}nnel 6 to it. If the graphics mode is 1 - 8, a split screen will be set up. For example, GRAPHICS 8 will set up a mode 8 sc>R}reen with a four line text window at the bottom.If 16 is added to the mode number, a full screen will be set-up. For examp>S}le, GRAPHICS 8+16 or GRAPHICS 24 will set up a mode 8 screen, with no text window, a full 192 pixels high. If the number 32 >T}is added to the mode number, the screen will not clear when the channel opens.27HIf you want to use a channel other than #>U}6, you will have to use the open command. It is used in the following format.screen open without GRAPHICS command OPEN >V}#channel,direction/special,mode,S:For example: OPEN #1,8,7,S:This will open channel 1 to a mode 7 screen for output on>W}ly. For use of special parameters, see ICAX1 above.USING AN OPEN CHANNEL TO THE SCREENOnce a channel is opened to the sc>X}reen it is used like any other input or output device. In other words, data is placed on the screen by the PRINT and PUT com>Y}mands. Data is retrieved from the screen with the INPUT and GET commands. The part of the screen which the data will be put>Z} in or taken from is determined by the X,Y coordinants in the database variables COLCRS [$0055,2 (85)] and ROWCRS [$0054 (84)>[}]. What appears on the screen depends on what graphics mode the computer is in.27GBefore sending data to the screen in BA>\}SIC, a color register must be assigned to the data. Once a point is plotted on the screen, it's color will be determined by >]}the color register it was assigned to.To assign a color to a ploted point, the COLOR command us used as follows.COLOR co>^}mmand format COLOR registerFor example, COLOR 1After using the above command, all points plotted will be controlled >_}by color register 1. To change color registers, use the COLOR command again.27HIn assembly language, the color is determi>`}ned by the data sent to the screen. See the above section on graphics modes for color information.27GIn BASIC the PLOT co>a}mmand is used to put data on the screen. The PLOT command is used as follows.The BASIC PLOT command PLOT x,y 11x and >b}y are the horizontal and vertical coordinates for the plotted point. 10In modes 3 through 11 a single point will be plotte>c}d. In modes 1 and 2 a text character will be printed on the screen by the PLOT command.The PRINT and PUT commands can also>d} be used in basic. What appears on the screen depends on the graphics mode.In modes 1 and 2 the ATASCII characters sent to>e} the screen will be printed just as in mode 0. See the paragraph on modes 1 and 2 above for more information. 27HIn the ot>f}her modes what appears depends on how the ANTIC chip interprets the data bytes sent to the screen. For example, in mode 8, e>g}ven numbered characters will be single pixels in color 1. Odd numbered characters will be in color 0 (background).27GTher>h}e are two special commands for the screen handler, DRAW and FILLDRAW 27H(ICCOM = $11 (17))27GThe draw command works exa>i}ctly like the plot command except a straight line is drawn from the previous pixel to the new one. In BASIC it is used in th>j}e following format.the BASIC DRAW command DRAWTO x,y27HFILL (ICCOM = $12 (18))Fill works like draw except the area>k} to the right of the drawn line will be filled with the color in FILDAT [$02FD (765)]. The fill command expects to find a bo>l}undary to the right. If no boundary is found, the entire horizontal screen between the ends of the line is filled.To use t>m}he fill command in BASIC the XIO command must be used in the following format. POSITION x,y XIO 18 #6,0,0,"E:"Note that >n}the cursor is first moved by the POSITION command. Below is an example of how to prepare for and use the fill command.usi>o}ng the fill command 2nd DRAWTO .____. DRAWTO here | | | | | | >p}fill to here ! ! PLOT hereThis will draw and fill a box on the screen.27GTHE COLOR REGISTERSThere are nine bytes >q}of memory which control the colors on the screen. These bytes are called color registers. 27HThe color registers have the >r}following names and relationships.D:CHAP8.3. These bytes are called color registers. 27HThe color registers have the <0Color registers and relationships 377Register Register modesname address 0 & 8 Bt} 1 & 2 3 5 7 4 & 6 9 & 11 10 HEX decimal COLOR numbersPCOLR0 $02C0 704 Bu} 0PCOLR1 $02C1 705 1PCOLR2 $02C2 Bv}706 2PCOLR3 $02C3 707 Bw} 3COLOR0 $02C4 708 0 - 63 1 1 4COLOR1 $02C5 709 1 - 255 64 -127 Bx}2 5COLOR2 $02C6 710 0 128-191 3 6COLOR3 $02C7 711 By} 192-255 7COLOR4 $02C8 712 border backgnd 0 backgnd backgnd 8Bz}The color numbers are in decimal. These are actually shadow registers. See the O.S. equates below for relationships. In mB{}odes 0 - 3 the COLOR number actually determines the character printedThe register to which a pixel/character is assigned toB|} is determined by the data byte sent to the screen through CIO. 1070The data in the color registers in in the following foB}}rmat.Color register data format 7 6 5 4 3 2 1 0 ----------------- | color |bright | B~} ----------------- color = one of 16 possible colors bright = one of 8 possible brightnesses (eB}ven numbers, 0 - E)27GIn basic, the COLOR command is used to assign color registers. The corresponding registers dependsB} on the graphics mode. For example, COLOR 0 is COLOR2 in mode 8. In most other modes COLOR 0 is COLOR4. See the above charB}t for the register relationships.To change the contents of the color registers in BASIC, the SETCOLOR command is used. In B}all modes except mode 10, the SETCOLOR command refers to the registers COLOR0 to COLOR4.SETCOLOR/register relationshipsB} SETCOLOR 0 COLPF0 (COLOR0) SETCOLOR 1 COLPF1 (COLOR1) SETCOLOR 2 COLPF2 (COLOR2) SETCOLB}OR 3 COLPF3 (COLOR3) SETCOLOR 4 COLBK (COLOR4)The format for the SETCOLOR command is...SETCOLOR commaB}nd format SETCOLOR register,hue,brightness register = 0 - 4 (0 - 8 in mode 10) hue = 0 - 15 (16 colors) brightB}ness = 0 - 16 (even numbers only (8 brightnesses)The following chart gives the colors represented by the hue number.coB}lors represented by hue numbers0 grey 8 blue1 gold 9 cyan2 gold-orange 10 blue-gB}reen3 red-orange 11 blue-green4 orange 12 green5 magenta 13 yellow-green6 purple-bluB}e 14 yellow7 blue 15 yellow-redThe attract modeIf a key is not pressed for more than 9 minutes the B}computer will enter the attract mode. This mode is used to prevent burning of the TV phosphors by lowering the brightness anB}d constantly changing the colors. 27HThe attract mode timer, ATRACT [$004D (77)], is set to 254 ($FE) when the the attract B}mode is entered. 27GTo force the computer out of the attract mode, poke a number less than 127 into ATRACT.27HUseful dB}atabase variables and OS equates 557APPMHI $000E,2 (14): lower limit for screen regionAB}TRACT $004D (77): attract mode timer and flagLMARGN $0052 (82): left marginRMARGN $0053 (83): right maB}rginROWCRS $0054 (84): horizontal cursor positionCOLCRS $0055,2 (85): vertical cursor positionDINDEX $0057 B} (87): current graphics modeSAVMSC $0058,2 (88): starting address of display bufferOLDROB}W $005A (90): previous cursor positionOLDCOL $005B,2 (91): " " "OLDCHR $005D (93): charaB}cter currently at the text cursorOLDADR $005E,2 (94): memory address of cursorRAMTOP $006A B} (106): end-of-RAM + 1 (MSB only)SDLSTL $0230,2 (560): shadow register of display list B}addressTXTROW $0290 (656): text window cursor positionTXTCOL $0291,2 (657): " " " "TXTMSC $0294,2B} (660): starting address of text window data bufferRAMSIZ $02E4 (740): permanent end-ofB}-RAM + 1 (MSB only)CRSINH $02F0 (752): cursor inhibit, 1 = no cursoB}rFILDAT $02FD (765): color data for fillDSPFLG $02FE (766): if >0 screen control codes B} are displayed as ATASCII characters (EOL is uneffected)SSFLAG $02FB}F (767): > 0 = stop screen printCOLPM0 $D012 (53266): actual color registersCOLPM1 $D013 (53267): loaded fromB} shadowCOLPM2 $D014 (53268): registers duringCOLPM3 $D015 (53269): vertical blankCOLPF0 $D016 (53270):COLPF1 B}$D017 (53271): see aboveCOLPF2 $D018 (53272): for useCOLPF3 $D019 (53273):COLBK $D020 (53274):OS shadB}ow registersnext pageOS shadow registersPCOLR0 $02C0 (704): COLPM0PCOLR1 $02C1 (705): COLPM1PCOLR2 $B}02C2 (706): COLPM2PCOLR3 $02C3 (707): COLPM3COLOR0 $02C4 (708): COLPF0COLOR1 $02C5 (709): COLPF1CB}OLOR2 $02C6 (710): COLPF2COLOR3 $02C7 (711): COLPF3COLOR4 $02C8 (712): COLBK $02C5 (709): COLPF1C@a12 4 1 5 0 10 70 2 12 1329-@27E27HCHAPTER 9THE RESIDENT DISK HANDLERThe resident disk handler is sepaF}rate from DOS and is part of the permanent operating system ROM. The disk handler does not use CIO.The resident disk handlF}er works with one sector at a time. It is used by setting the drive number, sector number, and operation code in the device F}control block. The program then jumps (JSR) to the handler entry vector, DSKINV [$E453 (58451)].Device control block (forF} resident disk handler) 11DDEVIC [$0300 (768)] Serial bus I.D. Set by handlerDUNIT [$0301 (769)] Drive numF}berDCOMND [$0302 (770)] Command byteDSTATS [$0303 (771)] status byteDBUFLO [$0304 (772)]DBUFHI [$0305 (773F})] 16Pointer to 128 byte memory block for data storage. 11DTIMLO [$0306 (774)] Timeout value (response time limit) F}in secondsDBYTLO [$0308 (776)]DBYTHI [$0309 (777)] number of bytes transferred, set by handlerDAUX1 [$030A (778)]F}DAUX2 [$030B (779)] sector number 10DISK HANDLER COMMANDSGET SECTORBefore the JSR to DSKINV is made the folloF}wing parameters are set.GET SECTOR parameters DCOMND = $52 (82) DUNIT = (1 - 4) DBUFHI and DBUF}FLO = address of 128 byte buffer DAUX1 and DAUX2 = Sector number (LSB,MSB)This operation will read the specF}ified sector and put the data into the specified buffer.PUT SECTORPUT SECTOR is used the same as GET SECTOR except for DCF}OMND.PUT SECTOR parameters DCOMND = $50 (80)This operation sends the data in the specified buffer to the specifiedF} disk sector.PUT SECTOR WITH VERIFYPUT SECTOR WITH VERIFY is used the same as PUT SECTOR except for DCOMND.PUT SECTOR F}WITH VERIFY parameters DCOMND = $57 (87)This operation sends the data in the specified buffer to the specified disk sF}ector then checks for errors.GET STATUSOnly the DUNIT and DCOMND need to be setGET STATUS parameters DCOMND = F}$53 (83) DUNIT = (1 - 4)The status information will be put in three bytes starting at DVSTAT [$02EA (746)].StatuF}s format 7 6 5 4 3 2 1 0 ----------------- DVSTAT + 0 | command stat | F} ----------------- + 1 | hardware stat | ----------------- F} + 2 | timeout value | -----------------The command status byte gives the following information.F} Bit 0 1 = invalid command frame received 1 1 = invalid data frame received 2 1 = unsuccessfulF} PUT operation 3 1 = disk is write protected 4 1 = active/standbyThe hardware status byte contains the staF}tus register of the ISN1771-1 disk controller chip.The timeout byte contains the maximum allowable response time for the drF}ive in seconds.FORMAT DISKThe handler will format then verify the the disk. The numbers of all bad sectors (up to 63) wiF}ll be put into the specified buffer followed by two bytes of $FF.The following parameters are set before the call.FORMAF}T parameters DCOMND = $21 (33) DUNIT = (1 - 4) DBUFLO and DBUFHI = address of bad sector list (bufF}fer)After the operation the status byte is set. Also, DBYTLO and DBYTHI will contain the number of bytes of bad sector infF}ormation (not including the two $FF bytes). 575Useful data base variables and OS equatesDVSTAT $02EA,3 (746): deF}vice status block, 3 bytesDDEVIC $0300 (768): serial bus I.D.DUNIT $0301 (769): device numberDCOMND $0302 F} (770): command byteDSTATS $0303 (771): status byteDBUFLO $0304 (772): data bufferDBUFHI $0305 (F}773): pointerDTIMLO $0306 (774): timeout valueDBYTLO $0308 (776): number of bytes transferedDBYTHI $0309 F} (777):DAUX1 $030A (778): sectorDAUX2 $030B (779): numberDSKINV $E453 (58451): disk handler entrF}y vector:DAUX1 $030A (778): sectorDAUX2 $030B (779): numberDSKINV $E453 (58451): disk handler entrD 12 4 1 5 0 10 70 2 12 13227E2710-@CHAPTER 10SYSTEM INTERRUPTSThere are four types of interrupts whicJ}h can occur with the 6502 microprocessor:6502 interrupts 1. chip reset 2. IRQ, interrupt request (maskableJ}) 3. MNI (non-maskable interrupt) 4. software interrupt (BRK instruction)CHIP RESETOn the 400/800 the chip J}reset occurs only upon power-up and causes the computer to do a cold start. On later models, pressing [SYSTEM RESET] will caJ}use a chip reset but the computer then does a warm start. On the 400/800, the [SYSTEM RESET] key generates a NMI interrupt.J}COLD STARTThis is a synopsis of the cold start routine. 111 15The warm start flag [$0008] is set to 0 (false) 112 15J}If a cartridge slot contains a diagnostic cartridge, control is handed to the cartridge. 113 15The end of RAM is determineJ}d by trying to complement the first byte of each 4K block of memory. 114 15Hardware registers at $D000 - $D4FF (except $D1J}00 - $D1FF) are cleared. 115 15RAM is cleared from $0008 to the top of ram. 116 15The user program jump vector, DOSVEC J}[$000A] is set to point to the black board mode (Atari logo display mode in XL/XE models). 117 15The screen margins are sJ}et to 2 and 39 118 15Interrupt vectors are initialized. 119 15Bottom of free RAM pointer, MEMLO [$02E7], is set to poinJ}t to $0700. 1110 15Resident CIO handlers are initialized. 1111 15If the [START] key is pressed the cassette boot requesJ}t flag, CKEY [$004A], is set. 1112 15The CIO device table is initialized. 1113 15If a cartridge is present it is initiaJ}lized. 1114 15Channel 0 is opened to the screen editor. The top-of-free-RAM pointer, MEMTOP [$02E5], is set to point beloJ}w the screen region. The computer then waits for the screen to be established before continuing. 1115 15If the cassette bJ}oot flag is set the cassette is booted. 1116 15If there is no cartridge present or a cartridge doesn't prevent it, the disJ}k is booted. 1117 15The cold start flag is reset. 1118 15If there is a cartridge present, the computer jumps to the carJ}tridge's run vector. 1119 15If there is no cartridge present the computer jumps through the vector DOSVEC [$000A (10)]. DJ}OSVEC will point to either a booted program, the memo pad routine (400/800) or the logo display routine (XL/XE).WARM STARTJ} 111 15The warm start flag is set to $7F (true). 112 15cold start steps 2 - 4 are executed. 113 15RAM is cleared frJ}om $0010 - $007F and $0200 - $03FF. 114 15Cold start steps 7 - 14 are executed. 115 15If cassette booted software is prJ}esent the computer JSRs through CASINI [$0002]. 116 15If disk booted software is present the computer JSRs through DOSINI J}[$000C (12)]. 10The difference between cold start and warm start is the condition of the warm start flag, WARMST, [$0008].J} If this flag is 0 a complete cold start is executed. If the flag is anything other than 0 then only the warm start part ofJ} the warm start/cold start code is executed.NON-MASKABLE INTERRUPTS (NMI)NMI interrupts are generated by the following coJ}nditions: 111. Display list interrupt, generated by the ANTIC chip.2. TV vertical blank interrupt, generated by the AJ}NTIC chip.3. [SYSTEM RESET] key (400/800). 10When an NMI interrupt occurs, the hardware register NMIST [$D40F] is J}examined to determine what type of interrupt occurred. The computer is then directed through the proper ram vector to servicJ}e the interrupt.DISPLAY LIST INTERRUPTS (DLIs)The computer makes no use of DLIs. The ram vector points to an RTI instrucJ}tion.VERTICAL BLANK INTERRUPTS (VBIs)There are two stages to the VBI service routine. The second stage is only done ifJ} a critical function was not interrupted.Stage 1 (VBI) 11The real time clock, RTCLOK [$0012 - $0014], is incremented.J}The attract mode variables are processed.System timer 1 is decremented. If it goes to zero the computer JSRs through systJ}em time-out vector 1. 10Stage 2 (VBI) 11The hardware registers are loaded with the data in their shadow registers.SyJ}stem timer 2 is decremented. If it goes to zero the computer JSRs through the system time-out vector 2.System timers 3, 4J}, and 5 are decremented. If a timer goes to zero the computer sets system timer flags 3, 4, and/or 5.If auto-repeat is acJ}tive, the auto-repeat process is done.The keyboard debounce timer is decremented if not 0.Information at the controller pJ}ort registers is read, processed and placed in the proper shadow registers. 10[SYSTEM RESET] INTERRUPTIf a [SYSTEM RESETJ}] interrupt is generated on the 400/800 the computer jumps to the warm start routine.D:CHAP10.1RRUPTIf a [SYSTEM RESETHdINTERRUPT REQUESTS (maskable interrupts (IRQs))When an IRQ interrupt occurs the hardware register IRQST [$D20E], the PIA stN}atus registers, PACTL [$D302] and PBCTL [$D303] are examined to determine what caused the interrupt.For each interrupt, theN} 6502 accumulator is pushed to the stack. The computer is then directed to the proper ram vector to service the interrupt.N}SOFTWARE INTERRUPT (BRK instruction)The operating system doesn't use software interrupts. The software interrupt vector poN}ints to a PLA followed by an RTI. 11Interrupt vectorsLabel address type functionVDSLST $0200 NMI DLI Points to aN}n RTIVVBLKI $0222 NMI stage 1 VBIVVBLKD $0224 NMI return-from-interrupt routineCDTMA1 $0226 NMI time-out 1 (used N}by SIO)CDTMA2 $0228 NMI time-out 2 (not used by OS)VPRCED $0202 IRQ not used (points to PLA,RTI)VINTER $0204 IRQ N}not used (PLA,RTI)VKEYBD $0208 IRQ keyboard interruptVSERIN $020A IRQ used by Serial I/O routineVSEROR $020C IRQ N}used by SIOVSEROC $020E IRQ used by SIOVTIMR1 $0210 IRQ not used by OS (PLA,RTI)VTIMR2 $0212 IRQ not used by OS (N}PLA,RTI)VTIMR4 $0214 IRQ ?VIMIRQ $0216 IRQ main IRQ codeVBREAK $0206 BRK unused by OS (PLA,RTI) 10SYSTEM TIMERN}SThe following timers are updated during vertical blank (VBI) as noted above. If a timer is decremented to 0 the computer N}jumps through it's associated vector or sets it's associated flag. 11Label address flag/vectorRTCLOK $0012 3 byte N}clock ($0012 = MSB)CDTMV1 $0218 CDTMA1 $0226 vector (SIO time-out)CDTMV2 $021A CDTMA2 $0228 vectorCDTMV3 $021C N}CDTMF3 $022A flagCDTMV4 $021E CDTMF4 $022C flagCDTMV5 $0220 CDTMF5 $022E flagHARDWARE INTERRUPT CONTROLThere aN}re two registers on the antic chip which control interrupts. These registers can be used to disable interrupts if necessary.N} There are also two associated interrupt status registers.The IRQ enable and status registers use the same address. The rN}esult is that reading the register does not reveal the enabled interrupts but the interrupts pending. IRQ interrupt enable dN}ata should usually be written to the OS shadow first. Reading the OS shadow tells which interrupts are enabled.Non maskabN}le interrupt enable 11NMIEN $D40E 7 6 5 4 3 2 1 0 ----------------- | | | not used | N} ----------------- bit 7 1 = DLI enabled 6 1 = VBI enabled 10Non maskable interrupt status 11NMIST $D4N}0F 7 6 5 4 3 2 1 0 ----------------- | | | | not used| ----------------- bit 7 1N} = DLI pending 6 1 = VBI pending 5 1 = [SYSTEM RESET] key pending 10Interrupt request enable 11IRQEN $DN}20E 7 6 5 4 3 2 1 0 ----------------- | | | | | | | | | ----------------- bit 7 N}1 = [BREAK] key interrupt enable 6 1 = keyboard interrupt enable 5 1 = serial input interrupt enable 4 1 = N}serial output interrupt enable 3 1 = serial output-finished interrupt enable 2 1 = timer 4 interrupt enable N}1 1 = timer 2 interrupt enable 0 1 = timer 1 interrupt enable IRQEN has a shadow register, POKMSK [$0010 (A)].InO}terrupt request status 11IRQST $D20E 7 6 5 4 3 2 1 0 ----------------- | | | | | | | | |O} ----------------- bit 7 1 = [BREAK] key interrupt pending 6 1 = keyboard interrupt pending 5 1 = seO}rial input interrupt pending 4 1 = serial output interrupt pending 3 1 = serial output-finished interrupt pendingO} 2 1 = timer 4 interrupt pending 1 1 = timer 2 interrupt pending 0 1 = timer 1 interrupt pending 10WAIT O}FOR HORIZONTAL SYNCWriting any number to WSYNC [$D40A (54282)] will cause the computer to stop and wait for the next TV horO}izontal sync.It is wise to use DLIs one TV line before needed then writing to WSYNC. This will keep other interrupts fromO} causing DLIs to be serviced late. This can cause a DLI to change something in the middle of a scan line. 5Useful databaO}se variables and OS equatesPOKMSK $0010 (16): IRQEN shadowIRQEN $D20E (53774): enables IRQs when written toIRQO}ST $D20E (53774); gives IRQs waiting when readPACTL $D302 (54018): bit 7 (read) peripheral A interrupt O } status bit 0 (write) peripheral A interrupt enablePBCTL $D303O } (54019): bit 7 (read) peripheral B interrupt status bit 0 (write) peripO }heral B interrupt enableWSYNC $D40A (54282): wait for horizontal syncNMIEN $D40E (54286): O }NMI enableNMIST $D40F (54287): NMI statusleWSYNC $D40A (54282): wait for horizontal syncNMIEN $D40E (54286): L/12 4 1 5 0 10 70 2 12 13227E27H11-@CHAPTER 11THE FLOATING POINT ARITHMETIC PACKAGEThe routines whichS} do floating point arithmetic are a part of the operating system ROM. The Atari computer uses the 6502's decimal math mode. S} This mode uses numbers represented in packed Binary Coded Decimal (BCD). This means that each byte of a floating point numbS}er holds two decimal digits. The actual method of representing a full number is complicated and probably not very important S}to a programmer. However, for those with the knowledge to use it, the format is given below.Floating point number represeS}ntation byte 0 xx excess 64 exponent + sign xx \ xx \ S} xx > 10 BCD digits xx / byte 7 xx /The decimal point is shifted to left of the S}MSD and the exponent is adjusted accordingly. Therefore, the decimal point doesn't need to be represented.For programming S}purposes, floating point numbers can be in ASCII code. It takes up to 14 bytes to store a floating point number in this mannS}er. The floating point package has a routine to convert numbers between ASCII and floating point.USE OF THE FLOATING POINTS} PACKAGEThe floating point package has several routines to convert between ASCII and FP and to do the arithmetic functions.S} These are the important data base variables.Floating point data base variablesFR0 $00D4,6 (212): 6 byte bufferS} for floating point numberFR1 $00E0,6 (224): 6 byte buffer for floating point S} numberCIX $00F2 (242): index for INBUFF addressINBUFF $00F3,2 (243): 2 byte pointer to ASCII floatinS}g point numberFLPTR $00FC,2 (252): 2 byte pointer to user buffer for S} floating point numberLBUFF $0580,? (1408): result buffer for FASC routineMAKING THE CALLTo do a floating point functS}ion, first set the proper pointers and JSR to the operation entry point. Below is a list of the entry points and parameters.S}ASCII to floating pointConverts ASCII representation pointed to by INBUFF to FP in FR0. AFP = $D800 INBUFF = addreS}ss of ASCII number CIX = buffer offset if any JSR AFPFLOATING POINT TO ASCIIConverts floating Point number in FS }R0 to ASCII. The result will be in LBUFF. INBUFF will point to the ASCII number which will have the bit 7 of the last byte S!}set to 1. FASC = $D8E6 JSR FASCINTEGER TO FLOATING POINT CONVERSION.Converts a 2 byte unsigned integer (0 to 65535)S"} in FR0 to floating point in FR0. IFP = $D9AA JSR IFPFLOATING POINT TO INTEGER CONVERSION.Converts floating point S#}number in FR0 to 2 byte integer in FR0. FPI = $D9D2 JSR FPI BCS overflowADDITIONAdds floating point numbers in FS$}R0 and FR1 with result in FR0. FADD = $DA66 JSR FADD BCS out of rangeSUBTRACTIONsubtracts FR1 from FR0 with theS%} result in FR0. FSUB = $DA60 JSR FSUB BCS out of rangeMULTIPLICATIONMultiplies FR0 by FR1 with the result in FR0.S&} FMUL = $DADB JSR FMUL BCS out of rangeDIVISIONDivides FR0 by FR1 with result in FR0. FDIV = $DB28 JSR FDIS'}V BCS out of range or divisor is 0LOGARITHMSPuts logarithm of FR0 in FR0 LOG = $DECD LOG10 = $DED1 JSR LOG ;fS(}or natural log.or JSR LOG10 ;for base 10 log. BCS negative number or overflowEXPONENTIATIONPut exponentiation of FS)}R0 in FR0 EXP = $DDC0 EXP10 = $DDCC JSR EXP ;for e ** Zor JSR EXP10 ;for 10 ** ZPOLYNOMIAL EVALUATIONPutsS*} the result of an n degree polynomial evaluation of FR0 in FR0. PLYEVL = $DD40 LDX LSB of pointer to list of floating pS+}oint coefficients, ordered high to low. LDY MSB of above LDA number of coefficients in list JSR PLYEVL BCS overflowS,}CLEAR FR0Sets FR0 to all zeroes ZFR0 = $DA44 JSR ZFR0CLEAR ZERO PAGE FLOATING POINT NUMBERClears user floatingS-} point number in page zero. ZF1 = $DA46 LDX address of zero page FP buffer JSR ZF1LOAD FR0 WITH FLOATING POINT NS.}UMBERLoads FR0 with user FP number in buffer pointed to by 6502 X and Y registers or by FLPTR. After either operation beloS/}w, FLPTR will point to the user FP buffer. FLD0R = $DD89 LDX lsb of pointer LDY msb JSR FLD0Ror FLD0P = $DD8DS0} FLPTR = address of FP number JSR FLD0PLOAD FR1 WITH FLOATING POINT NUMBERLoads FR1 with user FP number in buffer poS1}inted to by 6502 X and Y registers or by FLPTR. After either operation below, FLPTR will point to the user FP buffer. FLD1S2}R = $DD98 LDX lsb of pointer LDY msb JSR FLD1Ror FLD1P = $DD9C FLPTR = address of FP number JSR FLD1PSTOS3}RE FR0 IN USER BUFFERstores the contents of FR0 in user FP buffer pointed to by 6502 X and Y registers or by FLPTR. After S4}either operation below, FLPTR will point to the user FP buffer. FST0R = $DDA7 LDX lsb of pointer LDY msb JSR FST0RS5}or FST0P = $DDAB FLPTR = address of FP number JSR FST0PMOVE FR0 TO FR1Moves the contents of FR0 to FR1 FMOS6}VE = $DDB6 JSR FMOVEThe usual use sequence of the floating point package might be to: 11load FR0 and FR1 with FP numS7}bes from user specified buffersdo the maththen store FR0 in a user buffer. 10An alternative might be to: 11convert anS8} ASCII representation to FP (the result is automatically in FR0).move FR0 to FR1.Convert the second ASCII number.Do theS9} math.Convert FR0 back to ASCII.Store the number back into a user buffer. 10The floating point package uses the followS:}ing blocks of RAM.RAM used by floating point package $00D4 - $00FF $057E - $05FFIf the floating point pacS;}kage is not used the above ram is free. 575Useful data base variables and OS equatesFR0 $00D4,6 (212): systeS<}m FP bufferFR1 $00E0,6 (224): system FP bufferCIX $00F2 (242): INBUFF indexINBUFF $00F3,2 (243): poS=}inter to ASCII FP bufferFLPTR $00FC,2 (252): pointer to user FP bufferLBUFF $0580 (1408): result buffer for FPS>} to ASCIIAFP $D800 (55296): ASCII to FPFASC $D8E6 (55526): FP to ASCIIIFP $D9AA (55722): integer toS?} FPFPI $D9D2 (55762): FP to integerZFR0 $DA44 (55876): clear FR0ZF1 $DA46 (55878): clear zero page S@}FP bufferFSUB $DA60 (55904): FR0 - FR1FADD $DA66 (55910): FR0 + FR1FMUL $DADB (56027): FR0 * FR1FDIVSA} $DB28 (56104): FR0 / FR1FLD0R $DD89 (56713): load FR0 by X,Y pointerFLD0P $DD8D (56717): load FR0 by FLSB}PTR pointerFLD1R $DD98 (56728): load FR1 by X,Y pointerFLD1P $DD9C (56732): load FR1 by FLPTR pointerFST0R $DSC}DA7 (56743): store FR0 at buffer by X,Y pointerFST1P $DDAB (56747): store FR0 at buffer by FLPTR pointerFMOVE $SD}DDB6 (56758): move FR0 to FR1EXP $DDC0 (56768): e exponentiationEXP10 $DDCC (56780): base 10 exponentiatSE}ionPLYEVL $DD40 (56640): polynomial evaluationLOG $DECD (57037): natural log of FR0LOG10 $DED1 (57041):SF} base 10 log of FR0 (56640): polynomial evaluationLOG $DECD (57037): natural log of FR0LOG10 $DED1 (57041):P12 4 1 5 0 10 70 2 12 13227E27H12-@CHAPTER 12Boot software formatsThere are three ways which programWH}s may be booted (loaded automatically upon power-up): From the disk drive From the cassette recorder From a ROM cartridWI}geDISK BOOTED SOFTWAREThe disk drive is the primary source for programs (other than the BASIC interpreter in the computeWJ}r ROM). A program booted from disk must be a machine language program. Secondly, the program is arranged on disk in a diffeWK}rent manner from the DOS files.When the computer is first turned on, it will attempt to read a program starting at sector oWL}ne in disk drive one. The exceptions are, if a cartridge prevents the disk boot process or the [START] key is pressed. The WM}program is expected to use all 128 bytes of each sector.FORMAT OF A DISK BOOTED PROGRAMA disk booted program begins at seWN}ctor one on the disk and continues in sequence. The first six bytes of the first sector contain program information. The reWO}st of the bytes contain the program itself.Disk boot program header 1st byte $00 flags, stored in DFLAGS [$0240] WP} $xx number of sectors used by program $xx address to start load $xx WQ} $xx initialization address 6th byte $xx 7th byte $xx start of program 11The flags byte is usually unused WR}and should be zero.The load address is stored in BOOTAD [$0242,2 (578)].The initialization address is stored in DOSINI [$WS}000C,2 (12)]. 10After the program is completely loaded the computer will JSR to the address stored in DOSINI for initializWT}ation. It will then jump to the address stored in DOSVEC to run the program.The initialization part of the program should WU}set the bottom-of-free-RAM pointer, MEMLO [$02E7,2 (743)], to point to the end of the program + 1. This will protect the proWV}gram from the computer and other programs. The top-of-user-RAM pointer, APPMHI [$000E,2 (14)], is also usually set to point WW}to the same address. This will protect the program from the video hardware. It must also set DOSVEC [$000A,2 (10)] to actuaWX}lly point to the run address of the program. The initialization should of course end with and RTS. With DOSINI and DOSVEC pWY}roperly set, the program will restart up pressing the [SYSTEM RESET] key.Rmember that the load address of the program shouWZ}ld be six bytes before where you want the program to reside in memory. The six byte header will load at the specified start W[}address followed by the program.CASSETTE BOOTED SOFTWAREThe cassette boot process is nearly identical to the disk boot prW\}ocess. The processes are so similar that cassette boot programs can usually be transferred directly to disk and vice-versa. W]} The two differences are: 11The cassette is booted instead of the disk if the [START] key is pressed when the power is turnW^}ed on.A bug in early operating systems requires the booted program to turn off the cassette motor with the following commanW_}d. LDA #$3C STA PACTL [$D302] 10CARTRIDGE BOOTED SOFTWAREThe Atari 800 has two cartridge slots. All other modelW`}s have only one. The second cartridge slot, slot B on the 800, resides from $8000 to $9FFF. The first slot, slot A, residesWa} from $A000 to BFFF. If a cartridge is inserted in a slot it will disable any RAM in the same area.Slot A, which is presenWb}t in all models, can reside at the entire 16K used by both cartridges in the 800 ($8000 to $BFFF).Cartridges use the last sWc}ix bytes for boot information. In cartridge A these bytes are from $BFFA to $BFFF. In cartridge B they are from $9FFA to 9FWd}FF.last six bytes of a cartridge $9FFA or $BFFA xx start address xx 00 We} xx flag byte xx init address $9FFF or $BFFF xx Flag byte bit 0 1 Wf}= allow disk boot bit 2 0 = do not start cartridge after init bit 7 1 = cartridge takes control before OS iWg}s initializedThe initialization process for the cartridge should be similar to that for disk and cassettWh}e. A minimum of an RTS instruction is required.The third byte of the cartridge tailer is used by the OS to check for the pWi}resence of a cartridge. This byte must be zero.A 16K cartridge will use both cartridge areas and the cartridge B tailer arWj}ea can be used for program code.THE CARTRIDGE HARDWAREMost cartridges consist of two ROM chips on a single circuit board.Wk} Moreover, both chip sockets have identical pin assignments. In other words, the chips can be switched to opposite sockets Wl}and the cartridge will still work. The difference is in the chips themselves. On one chip, the A12 pin acts as an active-lWm}ow chip select. On the other the A12 pin acts as an active-high chip select. Therefore the state of the A12 pin selects betWn}ween the two chips.Cartridge slot pin assignments BACK 111111 543210987654Wo}321 --------------- --------------- SRPNMLKJHFEDCBA FRONT 15 Wp} 1 1 = 16K A A13 (16K only) 2 A3 B GND 3 A2 C A4 4 A1 D A5 Wq} 5 A0 E A6 6 D4 F A7 7 D5 H A8 8 D8 J A9 __ 9 DWr}1 K A12 (CS)/(CS) 10 D0 L D3 11 D6 __ M D7 12 (CS) N A11 13 +VWs}cc P A10 14 +Vcc R NC 15 NC S NC 10The BASIC interpreter resides in the memory useWt}d by cartridge A. In 400, 800 and 1200XL models, a BASIC cartridge is required to run BASIC programs. On other XL and XE moWu}dels, inserting a cartridge into the slot or pressing the [OPTION] key upon power-up will disable the internal BASIC ROM. IfWv} BASIC is disabled without inserting another cartridge, the area from $A000 to $BFFF will contain RAM. 575Useful data baWw}se variables and OS equatesAPPMHI $000E,2 (14): low limit of screen regionDOSVEC $000A,2 (10): run and prograWx}m reset vectorDOSINI $000C,2 (12): init and reset initCARTB $8000 (32768): start of cartridge BCARTA $A000 Wy} (40960): start of cartridge APACTL $D302 (54018): port A control register Bit 3 contrWz}ols the cassette motorrtridge APACTL $D302 (54018): port A control register Bit 3 contrT12 4 1 5 0 10 70 2 12 13227E27H13-@CHAPTER 13THE SERIAL INPUT/OUTPUT INTERFACE (SIO)Most input and o[|}utput with the Atari computer passes through the serial I/O bus. The SIO interface is rather complicated but you are unlikel[}}y to need to use it directly. CIO usually handles SIO for you. However, if you want to design your own I/O device and it's [~}associated handler, you need to know how to use the SIO.SIO transfers data at a rate of 19,200 baud on separate input and o[}utput lines. The data is sent one byte at a time, LSB first, in an asynchronous format. There are also clock-in and clock-o[}ut lines. There is a signal on the clock-out line but it is not used by any present devices. The clock-in line is available[} for synchronous transfer but is not used by the OS. The signal on the clock-out line goes high at the leading edge of each [}bit and goes low in the middle of each bit.One byte of SIO data +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ [} | | | | | | | | | | | | | | | | clock -------------+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +------ ---------+ [} +---+ +-------+ +-------- | 0 | 1 | 0 | 1 1 | 0 0 | 1 data +-------+ +---+ [} +-------+ | | start bit stop bit[}The SIO interface is used much like the resident disk handler. In fact, it uses the same device control block as the residen[}t disk handler. After the control block parameters are set, a JSR is made to the SIO entry vector, SIOV, at $E459 (58457).[}Device control block (for SIO) 11DDEVIC [$0300 (768)] Serial bus I.D. Set by handler or program.DUNIT [$0301 [}(769)] Device number if more than one.DCOMND [$0302 (770)] Device command byte.DSTATS [$0303 (771)] 16Befor[}e the SIO call, this byte tells whether the operation is read, write or that there is no data transfer associated with the co[}mmand. After the call this byte will hold the status (error/no error code) of the operation. 10DSTATS format before comm[}and 7 6 5 4 3 2 1 0 ----------------- |W|R| not used | ----------------- 11If both W[} and R are 0, there is no data transfer.DBUFLO [$0304 (772)]DBUFHI [$0305 (773)] 16Points to the data buffer for either [}input or output. 11DTIMLO [$0306 (774)] 16Timeout value (response time limit) in 64/60ths of a second to be set by handle[}r or program. 11DBYTLO [$0308 (776)]DBYTHI [$0309 (777)] 16Number of bytes to be transferred, set by handler or program.[} This parameter is not required if the DSTATS specifies no data transfer. 11DAUX1 [$030A (778)]DAUX2 [$030B (779)] 16[}These parameters are sent to the device as part of the command frame. 10USING THE SIO INTERFACEAll commands on the seri[}al bus must originate from the computer. The peripherals will present data on the bus only when commanded to do so.Any ope[}ration on the serial bus begins with a five byte command frame. While the command frame is being sent, the command line of t[}he serial connector is 0.Command frame format $xx DDEVIC $xx DCOMND $xx DAUX1 [}$xx DAUX2 $xx checksumThe first four bytes of the command frame come from the device control block. the checks[}um is the sum of the other four bytes with the carry added back after each addition.If both R and W of the DSTATS are 0, no[} data is sent to, or expected from the peripheral, after a command frame is sent. However, the device is usually expected to[} send an ACK byte ($41) after the command frame is sent. If the command frame is invalid, an NAK byte ($4E) should be sent.[}If the operation is output (W = 1) the computer will send a data frame after it receives the ACK of the command frame. It t[}hen expects an ACK after the data frame is sent.If the operation is an input (R = 1) the computer expects a data frame from[} the peripheral after the ACK. With either input or output, a "complete" code ($43) should be sent to the computer when the [}operation is finished. The "complete" code would follow the ACK of the data frame with an output operation.If the operatio[}n is not completed for some reason, the peripheral should send an error code ($45) instead of "complete".SIO data frame[} byte 1 $xx\ > data bytes byte n $xx/ byte n+1 $xx checksumSIO commandsREAD [} $52WRITE $57STATUS $53PUT $50FORMAT $21DOWNLOAD $20READADDR $54READ SPIN $51MOTOR ON $55VERI[}FY SECTOR $56Present SIO device I.D.sDISK $31 - $34 (D1 - D4)PRINTER $40RS-232-C $50 - $53 (R1 - R4)T[}HE SERIAL CONNECTORThe serial connectors on the computer and all peripherials are identical. Nearly all peripherials have [}two serial connectors. Either connector may be used for any connection. The serial bus is designed so that peripherials can[} be daisy-chained together. The following is a diagram of the serial connector.The serial connector pin-out [} 1 1 2 4 6 8 0 2 ----------- /o o o o o o\ /o o o o o o[} o\ ----------------- 1 3 5 7 9 1 1 1 3 15 1 clock in (to computer) 2 [} clock out 3 data in 4 GND 5 data out 6 GND 7 command (active low) 8 cassette motor control 9 proceed (active l[}ow)10 +5V/ready11 audio in12 +12V (400/800)13 interrupt (active low) 14Proceed goes to pin 40 (CA1) of the PIA. It[} is not used by present peripherials.Interrupt goes to pin 18 (CB1) of the PIA. It is not used by present peripherials.P[}in 10 doubles as a 50mA +5V peripharal power supply and a computer ready signal. 575Useful database variables and OS eq[}uatesSIOV $E459 (58457): serial port handler entryDDEVIC $0300 (768): device IDDUNIT $0301 (769): [}device numberDCOMND $0302 (770): command byteDSTATS $0303 (771): status byteDBUFLO $0304 (772): data [}buffer pointerDBUFHI $0305 (773):DTIMLO $0306 (774): timout valueDBYTLO $0308 (776): number of bytes [}to transferDBYTHI $0309 (777):DAUX1 $030A (778): sent to deviceDAUX2 $030B (779): sent to devices X{12 4 1 5 0 10 70 2 12 13227E27H14-@CHAPTER 14THE HARDWARE CHIPS27GThe previous chapters described t_}he operating system of the computer. The following chapters will examine the hardware which supports the 6502 and the hardwa_}re's associated software.THE GTIA CHIPThe GTIA (George's Television Interface Adapter) is the main video circuit in the c_}omputer. It controls the following functions.GTIA functions 11Priority of overlapping objectsColor and brightness, in_}cluding information from the antic chip.Player/missile control.console switches and game control triggers. 10THE ANTIC _}CHIPThe main job of the ANTIC chip is interpreting the display buffer for the GTIA chip. The ANTIC chip is somewhat of a p_}rocessor in it's own right. The program which runs it is called the display list and usually resides just before the display_} buffer in memory.The ANTIC chip operates independent of the 6502. It operates by direct memory access (DMA). The ANTIC c_}hip gives a HALT signal the 6502, causing the 6502 to give up control of the address bus. The ANTIC chip can then read any d_}ata it needs to from memory.ANTIC chip functions 11DMA (Direct Memory Access) control.NMI (Non-Maskable Interrupt) con_}trol.LIGHT PEN READINGWSYNC (wait for horizontal sync) 10THE POKEY CHIPThe most important jobs of the POKEY chip are_} reading the keyboard and operating the serial port. It also has the following functions.POKEY chip functions 11Keyboar_}d reading.Serial port.Pot (game paddles) reading.Sound generation.System timers.IRQ (maskable interrupt) control._}Random number generator. 10THE PIA CHIPThe PIA (Parallel Interface Adapter) is a commonly used I/O chip. It consists of_} two 8 bit parallel ports with hand shaking lines. In the Atari, it has the following functions. 11Game controller port c_}ontrol (bi-directional).Peripheral control and interrupt lines. 10Registers in the hardware chips are treated as memory_} addresses. Many of the registers are write only. These registers cannot be read from after they are written to. Other reg_}isters control one function when written to and give the status of an entirely different function when read from. Still othe_}r registers are strobes. Any command which causes the address of one of these registers to appear on the address bus will ca_}use their functions to be performed.The write only registers have shadow registers in RAM. Data to be put in the registers_} is usually put into the shadow registers. The data in the shadow registers is automatically moved to the operating register_}s during vertical blank.For register use and address, see the previous chaptes on the associated functions.rating register\n12 4 1 5 0 10 70 2 12 13227E27H15-@CHAPTER 15DISPLAY LISTSThe program which runs the ANTIC chip is cc}alled the display list. Much like a microprocessor, the ANTIC chip has a program counter, called the display list counter.c}The display list counter is a 16 bit register. However, the six most significant bits are semi-fixed. These bits can only bc}e changed with a jump instruction. The result of this is that the display list counter cannot cross a 1K memory boundary (i.c}e. $A3FF to $A400) without using a jump instruction.The ANTIC chip finds the address of the display list in DLISTL [$D402 (c}54274)] and DLISTH [$D403 (54275)]. SDLSTL [$0230 (560)] and SDLSTH [$0231 (561)] are the shadow registers for DLISTL and DLc}ISTH.The ANTIC chip also has a memory scan counter. This register scans the display buffer for data to be interpreted and c}displayed. Once loaded, the memory scan counter's 4 most significant bits are fixed. The result is that the memory scan couc}nter cannot cross a 4K memory boundary (i.e. $AFFF to $B000) without being reloaded.DISPLAY LIST INSTRUCTIONSThere are thc}ree basic instructions in the display list. The type of instruction is determined by bits 0,1,2 and 3 of an instruction bytec}. The other four bits give auxilliary parameters for the instruction. Bit 7 always enables a display list interrupts (DLIs)c}.Display list instruction format 7 6 5 4 3 2 1 0 ----------------- |I|n|n|n|0|0|0|0| ----------------- c} \ / \ / --- ------ | | | 0 = display blank lines | 0-7 =c} number of blank lines (1-8) 7 6 5 4 3 2 1 0 ----------------- |I|W| | |0|0|0|1| ----------------- c} | \ / | ------ | | | 1 = jump (3 byte instruction) | 0 = jumc}p and display one blank line 1 = jump and wait for vertical blank 7 6 5 4 3 2 1 0 ----------------- |I|c}R|H|V|M|M|M|M| ----------------- | | | | \ / | | | | ------ | | | | | | | | | 2-F = displc}ay one line of graphics in | | | | ANTIC mode 2-F | | | 1 = horizontal scroll enabled | | | | | c}1 = vertical scroll enabled | | | 1 = reload memory scan counter with next two bytes | 1 = display list ic}nterrupt, all instructionsIn the display instruction, the ANTIC mode is different from the CIO graphics mode. However, eac}ch CIO graphics mode uses a particular ANTIC mode. Below are descriptions of the ANTIC modes with their associated graphics c}(CIO) modes.ANTIC MODE 2 (Graphics 0)Uses 8 pixel by 8 pixel characters, 40 characters horizontal, 8 TV scan lines vertic}cal. Only one color can be displayed at a time.ANTIC MODE 38 X 10 pixel, Graphics 0 type characters. This mode requiresc} a custom character set. The advantage is that it allows true decenders. The custom C-set is still 8 X 8 pixels. Lower-casc}e letters with decenders have the bottom row of pixels put on the top row.Lower-case "y" for ANTIC mode 3 C-set c} Display ---------- ---------- | XXXXX | | | | | | | | c}| | | | XX XX | | XX XX | | XX XX | | XX XX | | XX XX | | XX XX | | XXXXX |c} | XXXXX | | XX | | XX | ---------- | XXXXX | | | c} ----------ANTIC MODE 4 (graphics 12 on XL and XE)This mode has characters the same size as graphics 0. However, thec} characters are only 4 X 8 pixels. This gives only half the horizontal resolution of graphics 0. The advantage is that up tc}o four colors of "graphics 0" characters can be displayed at once. This mode also requires a custom C-set. Below is a compac}rison of the normal C-set to one which works with the ANTIC 4 mode.Upper-case "A" for ANTIC modes 2 and 4 mode 2 c} mode 4 ---------- ---------- | | | | | XX | | yy | | XXXX | c} | yy | | XX XX | |xx zz | | XX XX | |xx zz | | XXXXXX | |xxyyzz | | XX XX | c} |xx zz | | | | | ---------- ---------- 11xx, yy and zz represent two bit binary numberc}s, controlling one pixel each. These numbers determine which color register a pixel is assigned to: (COLOR0, COLOR1, COLOR2 c}or COLOR3). 10ANTIC mode 5Antic mode five is identical to ANTIC mode 4 except the characters are displayed twice as tallc}. This makes only 12 lines on the screen.ANTIC MODE 6 (Graphics 1)This mode uses 8 X 8 pixel characters except they are c}displayed twice as wide as in ANTIC mode 2. There are 3 colors available at once but only one case (upper or lower) can be dc}isplayed at a time. The data base variable CHBAS [$02F4 (756)] controls the character, [$E0 (224) = upper-case, $E2 (226) = c}lower-case]The color/character is controlled by either the color statement or the ATASCII number of the character printed. c} Control characters are controlled by COLOR0, upper-case characters by COLOR1 and lower-case characters by COLOR2. Remember c}that all characters print as upper-case alpha characters, but of different colors.ANTIC MODE 7 (Graphics 2)This mode is ic}dentical to mode 6 except the characters are displayed twice as tall. This results in only 12 lines possible on the screen.c}ANTIC MODE 8 (Graphics 3)This is the first graphics (non-character) mode. This mode, as other non-character graphics modec}s do, uses data in the display buffer as a bit map to be displayed.A command to display in mode 8 will cause the ANTIC chipc} to read the next 10 bytes in the display buffer. Each pair of bits will control one pixel as in mode 4. However, the pixelc}s are blocks the same size as a Graphics 0 (ANTIC 2) characters.ANTIC MODE 9 (Graphics 4)This is similar to ANTIC mode 8 c}except each byte controls 8 pixels (instead of 4) and only one color can be displayed at a time. The pixels are also half thc}e size of those in ANTIC mode 8.ANTIC MODE A (Graphics 5)This mode uses 20 bytes per line/command. As in ANTIC mode 8, ec}ach pair of bits controls one pixel. The result is that the pixels are the same size as in ANTIC mode 9 but four colors can c}be displayed at once.ANTIC MODE B (Graphics 6)As in mode A, there are 8 pixels per byte and only one color. The pixels ac}re half the size as in mode A.ANTIC MODE CLike mode B except the pixels are half as tall (only one T.V. line).ANTIC MODc}E D (Graphics 7)40 Bytes per line, each byte controls 4 pixels. The pixels are 1/4 as large as in ANTIC mode 8 (Graphics 3c}).ANTIC MODE E (Graphics 15 on XL and XE)Like mode D except the pixels are half as tall (one T.V. line). Antic mode E isc} sometimes called Graphics 7.5ANTIC mode F (Graphics 8, 9, 10 and 11)This is the highest resolution mode. Pixels are 1/8c} the size of ANTIC mode 8 or mode 2 characters. It uses 40 bytes per line, each byte controlling 8 pixels, unless the GTIA cc}hip intervenes. Only one color can be displayed at a time.D:CHAP15.1, each byte controlling 8 pixels, unless the GTIA c`JDISPLAY LIST EXAMPLESWhen CIO opens a channel to the screen, it sets up the proper display list for the ANTIC chip. The fog}llowing are the things CIO must handle when setting up the display list.Display list duties as used by CIO 11display a d}