; MXC-MC10.ASM Mountain Clock rev. 1.0 ; ; MEXplus Clock Overlay for Apple II with PCPI Applicard and ; and Mountain CPS Card ; ; May be used even if CPS card isn't serial I/O for MEX or could be ; integrated into the Mixed overlay MXO-AP34 when making it into MXH-AP34 ; ; Adapted from CPS time routines extracted from MXO-AP34.ASM ; (thanks to Henry Middlebrook) ; additional info on the OKI 5832 clock chip can be found in Ciarcia's ; March 86 Byte article, pg. 113 ; ; this overlay could be adapted for the MCI "The Clock" by changing ; the index values used with CLKTBL ;------------------------------------------------------------------------ ; revision | date | description | author ;----------|------------------------------------------------------------- ; 1.0 |24Mar86 | created original | Jim Lill ;------------------------------------------------------------------------ ; CENTURY EQU 1900 ;CPS no got.. change in 2000 CPSLOT EQU 4 ;set for YOUR installation <====== CLKPORT EQU 0C0FEH + (CPSLOT * 100H) ;for reading CPS card CLKDATA EQU 0C0F9H + (CPSLOT * 100H) ; " " " " CLKHOLD EQU 040H ; " " " " CLKREAD EQU 050H ; " " " " RDBYTE EQU 0FFE0H ;Read a Byte from Apple (A = BYTE) WRBYTE EQU 0FFE3H ;Write a Byte to Apple (C = BYTE) RDWORD EQU 0FFE6H ;Read 2 Bytes from Apple (DE = BYTES) WRWORD EQU 0FFE9H ;Write 2 Bytes to Apple (DE = BYTES) RDNBYTS EQU 0FFECH ;Read N Bytes (DE = COUNT, HL = BUFFER) WRNBYTS EQU 0FFEFH ;Write N Bytes (DE = COUNT, HL = BUFFER) PEEK1BYTE EQU 6 ;Command to Peek 1 Byte in the Apple POKE1BYTE EQU 7 ;Command to Poke 1 Byte to the Apple ;--------------------------------------------------------------------- ; Start of MEX stuff.... this would be p/o a MXO ==> MXH upgrade too! ORG 0100H DB 0C3H ; this is for 8080 processor ;--------------------------------------------------------------------- ; JMP table for clock overlay ; ORG 0E00H ;start of clock overlay JMP GETTIM ;get time (uses new code) JMP GETDAT ;get date (uses new code) RET ;cset processor NOP NOP RET ;clock overlay init NOP NOP RET ;clock overlay de-init NOP NOP ;-------------------------- ; NEW CODE STARTS HERE .... this could be integrated into MXH-AP34 ;-------------------------- ; GETTIM, this routine is for the MEXplus MXC overlay ; gets the data in CLKTBL and readies it for MEX ; B - Hours (0-23) Note: MEX displays AM/PM, not 24 Hr time ; C - Minutes (0-59) ; D - Seconds (0-59) ; E - Hundredths of sec (0-99) Not used, so .00 loaded ; GETTIM: CALL GET$TIME ; go get time ; MVI A,4 ; index 4= hours CALL NIBBLES ; put hours into Accumul. CPI 80 ; see if CPS hours are >80 JC NOT$EIGHTY ; if not, jump SBI 80 ; if so, subtract eighty NOT$EIGHTY: MOV B,A ; move hour from Accumul. to B ; MVI A,2 ; index 2= minutes CALL NIBBLES ; put minutes into Accumul. MOV C,A ; move mins. from Accumul. to C ; MVI A,0 ; index 0= seconds CALL NIBBLES ; put secs. into Accumul. MOV D,A ; move secs. from Accumul. to D ; MVI E,0 ; CLKTBL doesn't have sec/100, so zero ; RET ; get back ;------------------------------------------------------------------ ; GETDAT, gets its' data from CLKTBL too ; BC - Year (1985-2099) this only works up to 1999, ; D - Month (1=Jan, 2=Feb, etc) then change CENTURY equate ; E - Day of Month (1-31) ; GETDAT: CALL GET$TIME ; go get date ; MVI A,9 ; index 9= month CALL NIBBLES ; put month in Accumul. MOV D,A ; move month from Accumul. to D ; MVI A,7 ; index 7= day of month CALL NIBBLES ; put day of month in Accumul. MOV E,A ; move day of month from Accumul. to E ; MVI A,11 ; index 11= year (00-99) CALL NIBBLES ; put year in Accumul. MOV C,A ; do Math. for complete year MVI B,0 ; so that 00-99 gets added to CENTURY LXI H,CENTURY ; eg: 86+1900= 1986 DAD B ; MOV C,L ; move answer into BC MOV B,H ; " " " " RET ;--------------------------------------------------------------------- ; NIBBLES --> converts the nibbles loaded into CLKTBL and returns ; a decimal result in the Accumulator. It uses an index ; value loaded into the accumulator to move down the table. ; This could be combined with GET$TIME, but was kept sep. ; for ease of integration into other CPS overlays ; NIBBLES: PUSH H ; save registers PUSH D ; " " MOV L,A ; form index into table using MVI H,0 ; HL as a pointer LXI D,CLKTBL ; " " " DAD D ; " " " ; MOV E,M ; load DE with two data bytes INX H ; from table, CLKTBL MOV D,M ; this and next could be combined ; as MOV A,M MOV A,D ; multiply most signif. byte by 10 ADD A ; " " " " " MOV D,A ; " " " " " ADD A ; " " " " " ADD A ; " " " " " ADD D ; " " " " " ADD E ; add the least signif. byte for answer ; POP D ; restore registers POP H ; " " ; RET ; return ; ;----------------------------------------------- ; All the following code came from MXO-AP34.ASM | ;----------------------------------------------- ; GET$TIME --> Reads CPS clock byte at a time and stores time in ; CLKTBL. ; GET$TIME: MVI A,CLKHOLD ;get byte to stop clock CALL WR$CLKSTAT ;send to CPS card MVI A,100 ;short little delay DLOOP: DCR A ;allows clock to settle JNZ DLOOP LXI D,CLKTBL ;put CLKTBL address in DE MVI B,0 ;set clock index to 0 ; TIME$LOOP: MVI A,CLKREAD ;get byte to read clock ORA B ;add clock index to read (50H - 5CH) CALL WR$CLKSTAT ;send to CPS card CALL RD$CLKDATA ;read clock (SEC1 --> YEAR10) ANI 0FH ;mask garbage in high nibble STAX D ;save value read in CLKTBL INX D ;bump CLKTBL address value in DE INR B ;bump clock index in BC MVI A,0DH ;fetch table length + 1 CMP B ;are we beyond end of table... JNZ TIME$LOOP ;no, then go back again XRA A ;yes, then zero A reg to turn on clock CALL WR$CLKSTAT RET ;...... ; ; FIXED DATA AREA FOR CLOCK FUNCTION ; ; The CLKTBL is fixed, initialized area used to store time as ; read from CPS clock hardware. ; ; | INDEX CLKTBL: DB 0 ; 0 S1 seconds units DB 0 ; S10 tens of seconds ;-------------------------------|---------------------------- DB 0 ; 2 MIN1 minutes units DB 0 ; MIN10 tens of minutes ;-------------------------------|---------------------------- DB 0 ; 4 H1 hours units DB 0 ; H10 tens of hours ;-------------------------------|---------------------------- DB 0 ; --- Day of Week, not used ;-------------------------------|---------------------------- DB 0 ; 7 D1 days units (of month) DB 0 ; D10 tens of days ;-------------------------------|---------------------------- DB 0 ; 9 MON1 months units DB 0 ; MON10 tens of months ;-------------------------------|---------------------------- DB 0 ; 11 Y1 years units DB 0 ; Y10 tens of years ;-------------------------------|---------------------------- AMPM: DB 0 ; --- 00H = AM, else = PM (not used) ;-------------------------------------------------------------- ; Write to CPS hardware to activate card for CLOCK functions ; WR$CLKSTAT: PUSH D LXI D,CLKPORT CALL POKE POP D RET ; ; ; Read a single byte from the CPS Card OKI 5832 clock chip ; RD$CLKDATA: PUSH D LXI D,CLKDATA CALL PEEK POP D RET ; ;--------------------------------------------------------------------- ; Peek at 1 byte from Apple 6502 address space ; ENTRY: DE = Address in Apple ; EXIT: A = Data ; PEEK: PUSH B MVI C,PEEK1BYTE CALL WRBYTE CALL WRWORD CALL RDBYTE POP B RET ; ; Š; Poke 1 byte to Apple 6502 address space ; ENTRY: DE = Address in Apple ; EXIT: A = Data ; POKE: PUSH B MOV B,A MVI C,POKE1BYTE CALL WRBYTE CALL WRWORD MOV C,B CALL WRBYTE POP B RET ; ; END