þþæ/ X;KEYCODE3.M65!X;Rewritten 11/87 by Bob HardyX;from an original program(X;by Bob Hardy2X;<X;Revision of 4/30/89FX;PX;ZFdEIn>D8:SYSEQU.M65x>D8:MACROLIB.M65‚>ŒD8:GREQU.M65Œ>D8:GRAPHICS.M65–X; X;---------ª X; Equates´X;---------¾X;ÈX;IOCB LOCATIONSÒX;--------------ÜX;æ#X; The IOCBs are the Atari's I/Oð"X; channels. They are a 'safe'ú$X; way to do I/O in that they are"X; always compatible and always$X; 'legal'. The worst you can do!X; with IOCBs is an I/O error."#X; There are no 'illegal' calls.,X;6X;ICCOM = $0342 ;command@#X;ICBAL = $0344 ;buf. adr., loJ#X;ICBAH = $0345 ;buf. adr., hiT#X;ICBLL = $0348 ;buf. len., lo^#X;ICBLH = $0349 ;buf. len., hihX;ICAX1 = $034A ;AUX1rX;ICAX2 = $034B ;AUX2|X;†X;OS REGISTERS, ETC.X;------------------šX;¤"X; These are too complex to try®$X; to document here. For details¸"X; see 'Mapping The Atari' fromÂX; COMPUTE! books.ÌX;ÖX;WARMST = $08à …BOOT? ê †POKMSKôX;LMARGN = $52þX;SAVMSC = $58†INVFLG¶†SHFLOK¾X;COLOR1 = $02C5 ;(709)&X;COLOR2 = $02C6 ;(710)0X;COLOR4 = $02C8 ;(712):†CRSINHðD ƒCH1òN…CHREGü;;(764)X†DSPFLGþb†CONSOLÐl …IRQENÒvˆPUTBYTES €X;Š X;VECTORS” X;-------žX;¨†COLDSTD²†KEYDELñ¼X;CIOV = $E456ƆWARMSVtäÐX;ÚX;ZERO-PAGE 2-BYTE POINTERSäX;-------------------------îX;ø †SCRPTRË …TXPTRÍ X;X;KEYPRESS VALUES: X;----------------*X;4X; CONSOLE KEYS>X;H †SELECTR …START\X;fX; ATASCII CHARACTERSpX;z …SPACE „X;EOL = $9BŽX;˜X; CHREG VALUES¢X;¬ …NOKEYÿ¶X;ÀX;Ê@ÔX;ÞƒTOPè,ò-ü ‡NOBREAK;; Disable BREAKQ†SAVMSC;; Store startP†SCRPTR;; adr of screenQ†SAVMSC;;memory in ZPG$P†SCRPTR;;screen pointer. …SETUP;; Print opening8!X; message andBX; wait forL$X; START keypressVX;` ‡RESTARTj ‡NOBREAK;;Kill BREAKtQ>;;Turn cursor~P†CRSINH;;on, normalˆP†DSPFLG;;CTRL chars’P†COLOR4;;Black borderœQ>;;Left margin=2¦ P†LMARGN°P†COLOR2;;Gray backgrndºQ> ;;White lettersÄ P†COLOR1Î$>4ˆMAINSCRN;;Print theØ%>5ˆMAINSCRN;;main scrnâQ>Zì …PRINTö …OPENK;;OPEN K:Q>…NOKEY;;Clear key reg  P…CHREGQ>;;Clear InverseP†INVFLG;;lock.(Q>@;;Set all CAPS2 P†SHFLOK< †KEYCHK;;Wait for key-F …KEYIN;;press & get keyP †CLOSE1;;Close K:ZQƒCH1;;Get last keydP†KEYBUF;;accepted &nX; store it.x ‡MAKEINT;;ATASCII code‚!X; is convertedŒ X; to internal–X; code and X; stored inªX; INTBUF´Q†KEYBUF;;Recover¾"X; keyboard codeÈ ‡MAKEDEC;;Convert toÒ#X; ATASCII digitsÜ%>æX;ð ‰MOVKEYDECúQ‡ATAHUNS8;;Move theP‡KEYBDEC8;;result to1;; KEYBDECI‰MOVKEYDEC"Q†KEYBUF;;Get keyboard, ‡HEXCONV;;code and6%>;;convert to HEX@X;J ‰MOVKEYHEXTQ‡ATAHUNS8;;Move the^P‡KEYBHEX8;;result toh1;; KEYBHEXrI‰MOVKEYHEX|Q†INTBUF;;Get internal† ‡MAKEDEC;;code & convert%>;;to ATASCIIšX;¤ ‰MOVHARDEC®Q‡ATAHUNS8;;Store the¸P‡HARDDEC8;;result inÂ1;; HARDDECÌI‰MOVHARDECÖQ†INTBUF;;Get internalà ‡HEXCONV;;code & convertê%>;;TO HEXôX;þŠMOVHARDHEXQ‡ATAHUNS8;;Move theP‡HARDHEX8;;result to1;; HARDHEX&IŠMOVHARDHEX0Q…ATBUF;;Get ATASCII: ‡MAKEDEC;;charcode andD%>;;convert to DECNX;X ˆMOVATDECbQ‡ATAHUNS8;;Store thelP…ATDEC8;; result inv 1;; ATDEC€ IˆMOVATDECŠQ…ATBUF;;Get ATASCII” ‡HEXCONV;;Convert to HEXž%>¨X;² ˆMOVATHEX¼Q‡ATAHUNS8;;and store theÆP…ATHEX8;;result in ATHEXÐ1Ú IˆMOVATHEXäQ>;;Turn cursor offî P†CRSINHø$>4†ATAMSG;;Print ATASCII%>5†ATAMSG;;message Q>†ATALEN;;msg. length …PRINT Q†SAVMSC;;Add $0170 to*,;;scrn ptr4O>p;;low byte...> P†SCRPTRHQ†SAVMSC;;high byte...RO>\P†SCRPTRfQ†INTBUF;;Get char &p%>;;poke it intozP@†SCRPTR7;;scrn RAM„$>4†KEYMSG;;Print hard-Ž%>5†KEYMSG;;ware message˜Q>‡KEYBLEN;;msg. length¢ …PRINT¬ …OPENK;;Clear any¶Q>…NOKEY;;keypresses...À P…CHREGÊ H†QUITS?Ô ˆDONTQUITÞ !†NOQUITèX;òX; Is the user finished?üX; †QUITS? Q†CONSOL;;Select press? R>†SELECT$ HˆDONTQUIT;;Nope.. $>4‡QUITMSG;;Yes!8 %>5‡QUITMSG;;Get user toB Q>‡QMSGLEN;;confirm.L …PRINTV  †KEYCHK;;Wait for key.`  …KEYIN;;Get keypress.j Q…ATBUFt M>;;ASCII only~ R> Y;;Was it "Y"?ˆ F„EXIT;;Yupper!’  †SCRPUT;;Nope. Print itœ †CLOSE1¦ Q>ƒEOL;;Print an EOL° †SCRPUTº  „GR.0;;purify screenÄ !‡RESTART;;and restart.Î ˆALLDONE?Ø !†QUITS?â †NOQUITì Q…CHREG;;No...ANY key?ö R>…NOKEY FˆALLDONE?;;No...  …KEYIN;;Yes!  †CLOSE1;;CLOSE K: Q…ATBUF;;Print the(  †SCRPUT;;key pressed2 !‡RESTART;;and restart.< X;F X; We're outa here.P X;Z „EXITd  †SCRPUT;;Print the keyn  †CLOSE1;;Close K:x  †CLOSE0;;Close E:‚ Q>…NOKEY;;Clear CHREGŒ P…CHREG– Q>ÿ;;Normal RESET  P†WARMST;;status.ª Q>;;Tell OS disk´ P…BOOT?;;boot was OK¾ Q>;;and no rebootÈ P†COLDST;;on warmstart.Ò  „GR.0;;Purify screen.Ü !†WARMSV;;Do warmstart.æ X;ð $X;-------------------------------ú X; "X; Subroutines -- what make the X; flow of the program work. X;" $X;-------------------------------, X;6 X;This is a general purpose@ X;"Put bytes to E:"J X;subroutine.T X;^ !X;Text address lo,hi is storedh X;upon entry in x,y.r X;Text length lo is stored| X;in A. Text length hi is† X;always assumed to be zero. X;š …PRINT¤ &…ICBAL;;Adrlo=X® $>;;IOCB#0 (E:)¸ P…ICBLL9;;Lenlo=A A;;Lenhi=0Ì P…ICBLH9Ö C;;Adrhi=Yà P…ICBAH9ê Q>ˆPUTBYTES;;Put cmnd.ô P…ICCOM9þ „CIOV !‡NOBREAK X; X;This subroutine prints the& X;character stored in the0 X;accumulator to the screen.: X;D †SCRPUTN 5;;Save A Reg.X $>;;IOCB #0b Al P…ICBLL9;;LEN=0v P…ICBLH9€ Q>ˆPUTBYTES;;Put cmnd.Š P…ICCOM9” 7;;Restore A andž !„CIOV;;print it.¨ X;² X; Do we or do we not have a¼ #X; keypress? KEYCHK waits untilÆ X; we get one.Ð X;Ú †KEYCHKä Q…CHREG;;Any keypress?î R>…NOKEYø F†KEYCHK;;Nope. :;;Yep! X; X; We have a keypress. Let's X; read it through IOCB #1.* !X; (where the keyboard happens4 X; to already be open!)> X;H …KEYINR $>;;IOCB #1\ Q>;;Get bytesf P…ICCOM9p Q>;;Lenlo=1z P…ICBLL9„ Q>;;Lenhi=0Ž P…ICBLH9˜ Q>4…ATBUF;;Point to¢ P…ICBAL9;; ATBUF¬ Q>5…ATBUF¶ P…ICBAH9À !„CIOVÊ X;Ô !X; Open the keyboard. NothingÞ "X; visible happens, but you canè !X; read from the keyboard now.ò X;ü …OPENK…OPEN ===A‚K:A:X;$"X; Close IOCB #1. End-of-file.."X; We got our keypress. G'bye!8X;B †CLOSE1L †CLOSE V:`X;j$X; Close IOCB #0. We're exiting.tX;~ †CLOSE0ˆ †CLOSE ’:œX;¦X; Turn ATASCII keycode into°X; hardware (internal) codeºX; and store the result inÄ X; INTBUF.ÎX;Ø ‡MAKEINTâQ…ATBUF;;Get ATASCIIìG…FIXHI;;If inv, fix.öX; …LOKEY R> ;;Key>31?E†MIDKEY;;Yes.,;;No - add 64.(O>@2P†INTBUF;;Conversion<:;;complete.FX;P †MIDKEYZR>`;;Key>95?dE…HIKEY;;Yes - fix.n;;;No - subtractxS> ;;32 from key.‚P†INTBUF;;ConversionŒ:;;complete.–X;  …HIKEYªR>€;;Key>127?´E…FIXHI;;Yes.¾P†INTBUF;;No - conversionÈ:;;unnecessary.ÒX;Ü …FIXHIæM>;;Clear bit 7ð …LOKEY;;Go do usualúL>€;;conversion,P†INTBUF;;reset bit 7,:;;and done.X;"$X; We don't want any BREAK errors,"X; crippling the program, so...6X;@ ‡NOBREAKJQ†POKMSK;;Disable theTM>;;BREAK key^ P†POKMSKh P…IRQENr:|X;†$X; We want a nice display for the"X; user to look at, and we wantš$X; the user to understand what is¤#X; going on. We'll dress up the®$X; screen a bit and print out our¸X; explanatory message.ÂX;Ì …SETUPÖ%>;;Black screenà'†COLOR2;;and borderê '†COLOR4ôQ> ;;White textþ P†COLOR1Q>4‡INTROTX;;Point TXPTRP…TXPTR;; at INTROTXQ>5‡INTROTX& P…TXPTR0X;: ˆFASTPRNTDQ@…TXPTR7;;Get scrntextNR>€;;Last char?XFˆSTARTPRS;;Yes-chk STARTbP@†SCRPTR7;;No, movel3;;char to scrmemv HˆFASTPRNT€#†SCRPTR;;Step up SCRPTRŠ#…TXPTR;; and TXPTR” HˆFASTPRNTžX;¨ ˆSTARTPRS²Q†CONSOL;; START pressed?¼ R>…STARTÆHˆSTARTPRS;;Nope!Ð :;; Yes!ÚX;ä„GR.0;Keep the macroî!‰GRAPHICS ;;from needlesslyø:;;being reassembledX; $X;-------------------------------X; #X; Buffers, text & storage space*X;4$X;------------------------------->X;H †KEYBUFR\ †INTBUFfp …ATBUFz„X;Ž ˆMAINSCRN˜" }=ƒEOL=AŽKeycode GetterA=ƒEOL¢1 A Written by Bob Hardy with MAC/65A=ƒEOL=ƒEOL¬6 A¥Press a key for which you want codes:A=ƒEOL=ƒEOL¶ †ATAMSGÀ ƒEOL=ƒEOLÊ AˆATASCII:A=ƒEOLÔ A‰Char: A=ƒEOLÞ A…Dec: AèX;ò …ATDECü A‹ Hex: $AX; …ATHEX Aƒ A=ƒEOL=ƒEOL$†ATALEN †ATAMSG.X;8 †KEYMSGB AŽHardware code:A=ƒEOLL A…Dec: AV ‡HARDDEC` A‹ Hex: $AjX;t ‡HARDHEX~ Aƒ A=ƒEOL=ƒEOLˆX;’ AŽKeyboard code:A=ƒEOLœ A…Dec: A¦X;° ‡KEYBDECº A‹ Hex: $AÄX;Î ‡KEYBHEXØ Aƒ A=ƒEOL=ƒEOL=ƒEOL=ƒEOLâ' A›Press to continue.A=ƒEOLì# A—Press