AN INTEGRAL REAL TIME CLOCK FOR THE PCPI APPLICARD P C P I - R T C . C O M 1. SUMMARY Thió ió thå .DOÃ filå foò PCPI-RTC.LBR® Iô describeó thå implementatioî oæ á real-timå clocë (RTC© anä á "time¢ BIOÓ calì foò thå PCPÉ Applicard (c)¬ makinç uså oæ thå on-boarä CTÃ chip. Modificationó arå requireä tï thå CCÐ anä BIOS¬ anä additionaì codå musô bå placeä above the toð oæ CP/Í. Aó thå clocë makeó uså oæ thå Applicarä hardware¬ iô musô bå restarteä aô eacè poweò on® Thå clocë wilì survivå á warí booô (control-C)® Anù uså oæ thå Applå keù wilì disablå thå clock, which must then be restarted. Thió particulaò implementatioî ió foò uså witè á ZCPR² CCP® However¬ thå principleó whicè arå useä shoulä allo÷ the codå tï bå readily adapteä foò otheò CCPs. 2. APPLICARD HARDWARE Througèouô theså notes¬ referencå wilì bå madå tï thå APPLICARD® Thå Z80Â CP/Í carä useä bù Frankliî foò thå Frankliî ACÅ 120° (c© ió identicaì tï thå APPLICARD® Thå STARCARÄ (c)¬ whicè coulä bå purchaseä aó á packagå witè Wordstaò (c)¬ ió alsï thå samå card¬ excepô thaô nï Z80B-CTÃ waó fitteä tï thió version® 3. THE Z80B-CTC CHIP Thå Z80B-CTÃ chið ió noô essentiaì tï standarä uså oæ thå APPLICARD¬ buô itó operatioî ió supporteä bù thå APPLICARD hard warå anä I/Ï porô protocol® Tï allo÷ thió RTÃ tï operate¬ á Z80B-CTÃ chið musô bå presenô iî thå 2¸ piî sockeô (chið indenô markinç facinç towardó thå 64Ë memorù chips© provideä foò iô oî thå Applicard® Aó itó namå suggests¬ thå Z80B-CTÃ provideó botè counteò anä timeò functions® Thió RTÃ implementatioî useó thå chið iî thå timeò mode® Detailó oæ operatioî oæ thå Z80B-CTÃ maù bå obtaineä froí manufacturers' data sheets or other references, such as Ref.1. 4. PCPI SOFTWARE VERSIONS Thió RTÃ waó developeä using¬ anä assuming¬ PCPÉ CP/Í Versioî 2.° anä INSTALL.COÍ versioî 2.7® Š 5. CHANGES TO CP/M FOR RTC IMPLEMENTATION 5.1 CHANGES TO THE CCP Á minoò changå ió requireä tï thå CCP¬ tï ensurå thaô      thå timå prompô onlù showó wheî waitinç aô thå CP/Í commanä      line anä noô aô otheò timeó, sucè aó wheî programó uså thå      BDOS Read Console Buffer (0Ah) or BIOS CONIN functions. PCPI-RTC.COÍ waó developeä foò á ZCPR² CCP® However¬      thå changå ió oæ sucè á minoò naturå thaô otheò CCÐ      implementationó maù bå expecteä tï bå modifieä withouô majoò      difficulty® Thå followinç ió thå sectioî oæ thå ZCPR²      source code which must be modified:- . . .           ; INPUT COMMAND LINE FROM USER CONSOLE           ;           RB1:            CALÌ SUBKIÌ ;ERASÅ $$$.SUÂ IÆ PRESENT           ;            ENDIÆ ;SUBON           ;            MVÉ A,CPRMPÔ ;PRINÔ PROMPT            CALÌ CONOUT           ;            XRÁ A ; ***            DCÒ A ; *** Added code            STÁ CCPFLG ; ***           ;            MVÉ C,0AÈ ;REAÄ COMMANÄ LINÅ FROÍ USER            LXÉ D,BUFSIZ            CALÌ BDOS           ;            XRÁ A ; *** Added            STÁ CCPFLG ; *** code . . . In addition a new EQUate must be defined CCPFLG EQU 0FF90h 5.2 THE BDOS Nï changeó arå requireä tï bå madå tï thå PCPICPÍ BDOS.      5.³ Changeó tï thå BIOS       Alì changeó tï thå BIOÓ arå madå automaticallù wheî      PCPI-RTC.COM is executed. Š6. INSTALLATION OF THE RTC Installatioî oæ thió RTÃ requireó thå followinç softwarå changes: - Á minoò patcè iî thå CCÐ tï telì thå softwarå onlù tï           prinô thå timå prompô wheî waitinç aô thå CCÐ commanä           linå foò CP/Í commandó tï bå entered (see section 5.1) - PCPICPÍ musô bå moveä loweò iî memorù witè INSTALL.COM¬           tï allo÷ spacå abovå iô foò thå RTÃ routines. Tï begiî installation¬ ruî PCPI-RTC.COÍ aó yoõ woulä anù otheò .COÍ program® Iæ yoõ havå á standarä Applicarä system¬ thå installatioî wilì bå aborted¬ becauså therå wilì bå insufficienô memorù spacå abovå PCPICPÍ tï inserô thå RTÃ routines® However¬ PCPI-RTÃ wilì telì yoõ thå Toð oæ Memorù valuå tï bå useä iî á ne÷ installatioî usinç INSTALL.COM® Proceeä witè á ne÷ INSTALLatioî (INSTALL.COÍ versioî 2.7© anä uså thå shoulä bå displayed¬ anä wilì bå updateä everù second. 7. RTC BIOS CALL Runninç PCPI-RTC.COÍ wilì alsï instalì entrù intï thå BIOÓ jumð table® Thió jumð haó aî offseô oæ 33è abovå thå starô oæ thå jumð table® Iæ á CALÌ ió madå tï thió address¬ thå addresó oæ thå beginninç oæ thå timå strinç wilì bå returneä iî thå HÌ register® Thå timå strinç wilì havå thå forí HH:MM:SÓ (thå coloî symboló arå presenô iî thå string). Prograí GET-TIME.COM¬ provideä iî thió library¬ demonstrateó thå uså oæ thió CALL. 8. TECHNICAL DETAILS PCPI-RTC.AZÍ ió writteî iî Ziloç Z8° mnemonics® Thió waó donå aó thå codå ió specifiã tï thå Applicard¬ whicè alwayó useó á Z80¬ and¬ therefore¬ therå waó nï neeä tï generalizå thå codå foò thå 808° familù oæ processors® Thå Ziloç mnemonicó havå thå Šadvantagå oæ accesó tï thå morå comprehensivå anä efficienô Z8° instructioî set¬ anä expresó thå codå iî á morå logicaì waù thaî 808° mnemonics. PCPI-RTC.AZÍ waó assembleä usinç Z80MR.COM¬ thougè otheò Zilog Z80 assemblers may also be used. Thå prograí "Welcome¢ messagå ió precedeä bù á "cleaò screen¢ function® Thió ió thå onlù terminaì controì sequencå whicè maù requirå alteration¬ dependinç oî thå specifiã 80-columî carä whicè ió used® Aó implemented¬ thå Cleaò Screeî code¬ aô CLRSCRº ió 1Bh¬ 2Ah® Thió maù bå changed¬ iæ desired¬ anä PCPI- RTC.AZÍ re-assembled. Thå run-timå codå foò PCPI-RTC.COÍ ió locateä abovå thå normaì highesô memorù locatioî useä bù CP/Í anä beneatè thå speciaì codå useä bù thå Applicarä (0FF80è - 0FFFFh© and¬ iî thå caså oæ ZCPR2¬ higè memorù spacå whicè maù bå useä foò thå externaì stack¬ multicommanä buffeò anä FCB® Á checë ió madå tï determinå thå sizå oæ thå codå whicè musô bå relocateä abovå CP/Í (BIOSJPº tï FINISH:© anä iô ió theî determineä whetheò thió codå wilì fiô iî thå spacå whicè ió availablå abovå CP/M® Thió makeó uså oæ thå CP/Í "Toð oæ Memory¢ worä whicè ió locateä iî thå CP/Í BIOÓ aô locatioî 0xx3Eè (wherå xø ió thå firsô pagå oæ thå BIOS» defaulô ½ F2)® Iî makinç thå spacå calculation¬ thå valuå HISPCEº ió useä tï contaiî thå lengtè oæ thå speciaì higè memorù Applicarä codå anä thaô useä bù ZCPR2)® Thió valuå maù requirå tï bå changeä foò otheò CCPs. Iæ therå ió insufficienô spacå foò thå relocateä PCPI- RTC.COÍ run-timå code¬ thå requireä Toð oæ Memorù ió calculateä (tï thå nearesô 1/² page© anä displayeä tï thå operator® Thió valuå maù theî bå useä aó thå basió oæ á ne÷ systeí generatioî, usinç INSTALL.COM® Wheî thå installatioî failó iî thió way¬ thå valuå oæ CCPFLGº (thå flaç whicè causeó thå timå strinç onlù tï bå printeä aô thå CP/Í prompt© ió alsï displayed® Thió ió currentlù seô aô 0FF90h¬ á locatioî whicè ió believeä tï bå unuseä by thå Applicarä system® Followinç thió failurå, thå prograí returnó controì tï thå CCP¬ withouô á warí boot® aó thå CCÐ haó noô beeî overwritten. Iæ sufficienô spacå ió founä abovå CP/M¬ aî "OK¢ messagå ió displayeä tï thió effecô anä thå prograí theî checkó tï seå whetheò PCPI-RTC.COÍ haó alreadù beeî run¬ anä thå BIOÓ patcheó anä relocateä run-timå codå arå alreadù iî place® Iæ thió ió thå caså thå operatoò ió theî askeä tï seô thå clock® Otherwiså thå clocë musô bå set¬ afteò thå codå haó beeî relocateä anä patcheó made. Iæ thió ió á ne÷ installation¬ afteò power-oî oò á colä boot¬ thå run-timå codå betweeî BIOSJPº anä FINISHº ió relocateä intï thå availablå memorù spacå abovå CP/Í anä variouó patcheó arå undertakeî tï reflecô thå exacô locatioî oæ thå CCÐ anä BIOS. Thå standarä Applicarä BIOÓ undertakeó thå CONIÎ functioî Šwithouô firsô checkinç inpuô status® Tï allo÷ thå opportunitù foò thå timå tï bå updated¬ thå codå musô waiô iî á looð whicè includeó thió statuó check® Tï achievå this¬ thå BIOÓ CONIÎ functioî musô bå patcheä tï redirecô executioî througè somå oæ thå PCPI-RTC.COÍ run-timå code® Thå flaç TIMFLGº ió monitoreä iî thió looð tï determinå whetheò anotheò seconä haó elapseä anä thå displaù shoulä bå updateä (aó lonç aó CCPFLGº ió set). Iî ordeò tï properlù displaù thå CP/Í commanä linå witè thå updateä time¬ iô ió necessarù tï re-displaù thå commanä line¬ uð tï thå poinô where thå operatoò haó typed® Thió ió accomplisheä bù referencinç thå locatioî oæ thå consolå commanä buffeò (whicè haó earlieò beeî patcheä intï thå codå durinç thå re-locatioî operation© anä obtaininç thå characteò counô whicè existó oî thå BDOÓ stack® Thå du¾ informatioî musô alsï bå obtaineä froí locatioî 0004. Thå interrupô vectoò musô bå seô tï direcô interruptó tï thå PCPI-RTC.COÍ run-timå code® Thå interrupô vectoò ió storeä iî twï places® Oncå aô locatioî 0FF84è (CTÃ channeì ² ió used¬ thougè anù oæ thå channeló maù bå used© anä alsï iî thå BIOÓ aô thå jumð tablå warí booô jumð locatioî « 011Ch® Thå BIOÓ entrù musô bå patched¬ aó iô ió froí herå thaô thå addresó vectoò ió copieä intï 0FF84h¬ wheî á warí booô occurs)® Thå ne÷ clocë BIOÓ calì musô alsï bå patcheä intï thå BIOÓ jumð table® Iî thå standarä BIOS¬ therå existó á jumð whicè ió jumpeä tï bù thå coldbooô jump® Thió appearó tï bå aî unnecessarù doublå jump® Thió space¬ aô thå enä oæ thå table¬ ió useä tï placå á jumð tï codå whicè returns¬ iî thå HÌ register¬ thå addresó oæ thå timå strinç. Foò thå clocë tï ruî, thå CTÃ ió seô uð witè thå correcô timeò value® Thió RTÃ makeó uså oæ thå Z80B-CTÃ chið iî thå "timer¢ mode® Iô ió useä witè thå 25¶ scaleò ON® Thå RTÃ initializatioî routinå provideä iî PCPI-RTÃ loadó á timå constanô (0FÃ hex¬ 25² dec© intï thå Z80B-CTC® This¬ togetheò witè thå 25¶ scaler¬ causeó aî interrupô tï bå generateä approximatelù everù 1° milliseconds® Thå interrupô servicå routine¬ tï whicè controì ió vectoreä wheî thå interrupô takeó place¬ normallù accumulatesó á count¬ anä returnó controì tï thå pre-interrupô condition® Whenever¬ thå counô reacheó á valuå oæ 9² (5Ã hex)¬ anotheò seconä haó elapseä anä thå timå timå strinç ió incrementeä bù onå second® Á flaç (TIMFLG© ió theî seô tï indicatå thaô thå timå strinç haó changed® Thå totaì perioä oæ thå clocë updatå is¬ therefore¬ defineä by:-           Clock perioä ½ 25¶ ø 92 x 25² x 0.1666· ¯ 100° ½ approø 1 second     (wherå 0.1666· ió thå perioä oæ thå ¶ MHú Applicarä          clock). Thió interrupô sequencå takeó placå regardlesó oæ whetheò Šthå timå ió diplayeä anä updateä oî thå console. 9. OTHER CCPs Thió codå haó beeî developeä specificallù foò thå ZCPR² CCP® Iî principle¬ thå codå shoulä bå fairlù easilù adaptablå tï otheò CCPs¬ sucè aó thå originaì useä iî PCPICPÍ anä alsï ZCPR3® Aó lonç aó thå originaì BIOÓ remainó thå same¬ sï faò aó thå patchinç locationó arå concerned¬ thå changeó tï thå codå shoulä bå minimal® Á differenô BDOÓ maù requirå changeó tï thå codå wherå thå commnaä linå ió extracted¬ iæ thå BDOÓ stacë ió differently organised. 9. Further Development Changeó arå currentlù beinç considered¬ whicè maù bå implementeä iî lateò versionó oæ PCPI-RTC.AZM® Therå maù bå á possibilitù oæ thå clocë "surviving¢ aî Applå ¬ oò anù oæ thå Applicarä