[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PRODOS file date query



Cortland driver:


CCLOCK_P1	PROC org $00D742
procstart

;	This EdAsm/Asm816 source code file was converted to AsmIIGS
;	by EdAsmCVTIIGS version 1.0D3 on 1/24/89 at 9:8:46 AM

* Converted and reformatted by Monte Benaresh -- February 1989

		MACHINE M65816		; Must go here for 24 bit expressions.

***********************************************************
*
*       ProDOS 8 CORTLAND CLOCK DRIVER
*
*         COPYRIGHT APPLE COMPUTER, INC., 1986
*
*         ALL RIGHTS RESERVED
*
*       Written by Kerry Laidlaw, 2/12/86
*       Modified by Mike Askins, 9/6/86
*       Modified by Fern Bachman, 9/7/86
*	Modified by Greg Branche, 6/12/91
*
***********************************************************
*
* This is the ProDOS8 Cortland built-in clock driver.
* Its sole function in life is to fetch the time from the Cortland
* clock via the Read Hex Time misc. tool call, and transfer this
* time into the ProDOS global page time format.
*
* This routine will IGNORE any errors passed back to it from the
* Read Hex Time call.  This was done since existing ProDOS8 programs
* cannot deal with some new time error code.
* Thus the only way that a user can tell if his Cortland clock is
* broken, is by noticing that the date and time fields are zeroed.
*
* Note: There are some interesting facts to know regarding the
* slot clock driver for ProDOS8 and the built-in
* Cortland clock.  The year value returned from the Cortland clock
* is an offset from the year 1900.  Thus Cortland is capable of
* reporting the year correctly until 1900+255=2155.  Only 7 bits
* are used for the year in the ProDOS8 global page, so theoretically
* 1900+127=2027 is the last year that ProDOS could represent on a
* Cortland.  But this is only if the ProDOS8 year value is interpreted
* as being an offset from 1900.
*
* Historically, the year value has been interpreted as the binary
* representation of the last two digits of the year 19xx.
* So this means that programs that display the year as a concatination
* of 19 and the ascii equivalent of the year value will work until
1999.
* And programs that just display the last two digits of the year will
* still work correctly until (20)27 if they convert the year value
* correctly, but ignore any hundredths place digit.
*
* Apple //e's that use slot clocks that utilize the slot clock
* driver have further restrictions of the year value.  The slot
* clock driver calculates the year given the position of the day
* of the week in the month.  This algorithm then uses a year look
* up table that has seven possible values.  Leap years are repeated
* in the table.  Since 1988 is a leap year, then the updated slot
* clock driver (file TCLOCK) will yield the six year offset values
* rather then seven.
* So before 1992, if ProDOS8 still exists, the slot clock driver
* routine must be updated again!
*
* So, we now have the following definition:
*    The value placed in the year field is defined as the
*    number of years past the year 1900.
*    Numerically speaking: Current Year = 1900 + year value.
*
*
* 12 Jun 91 - Greg Branche
* Well, it's time to alter the above definition a little, since we now
* have ProDOS Tech Note #28, which defines the year a little
differently.
* In accordance with the tech note, this driver will now supply only a
* two digit year value, with a range of 0-99.  Any year value from 40
to
* 99 is interpreted to be in the 20th century (19xx).  Year values
from
* 0-39 are interpreted to be in the 21st century (20xx).
*
STATEREG	EQU	$C068	 	;Cortland memory state register
CLOCK_BEGIN	EQU	$D742	 	; Entry address of Cortland clock driver.
MISC_TSN	EQU	3	 	; Misc. tool set number.
READ_TIME_HEX	EQU	$0D	 	; Read Time Hex function number.
DISPATCH	EQU	$E10000	 	; Tool Dispatcher entry address.
MINUTES		EQU	$BF92	 	; Minutes in ProDOS global page.
HOURS		EQU	$BF93
YEAR		EQU	$BF91
DAY		EQU	$BF90
*
*
************************* See Note #66,67 *************************
*
* This mod will force read/write main memory for the tool
* call by resetting the read/write auxillary memory bits
* in the state register (statereg).
*
		LONGA	OFF
		SEP	#$30		 ;Make sure we're in 8 bit mode
		LDA	STATEREG	 ;Get the state reg
		STA	SAVESTATE	 ;Keep for restore after tool call
		AND	#$CF		 ;Clear the Read/Write aux memory bits
		STA	STATEREG	 ;Make it real
*
***************************************************************
*
		LONGI ON
		LONGA ON
*
* First off, lets get into native mode with 16 bit m & x.
*
		CLC 			; Set e = 0, to set native mode.
		XCE

		REP	#$30		; Zero m & x for 16 bit mode.
		LDA	#0		; Zero out result space.
		PHA			; Push 4 words for hex time result...
		PHA
		PHA
		PHA
		LDX	#READ_TIME_HEX * $100 + MISC_TSN	 ; Read Time Hex.
		JSL	>DISPATCH	; Make the ReadTimeHex call...
*
* Note that no error condition is checked for, so the date will
* be zeroed by default if an error indeed happened.
*
*  Back to 8 bit m to access results on stack...
*
		LONGA	OFF
		SEP	#$20	 	; 8 bit m
*
************************* See Note #66 *************************
*
		LDA	SAVESTATE	;Restore the state register
		STA	STATEREG
*
***************************************************************
*
*
* Now let's pull the time off the stack and stick it in the global
page.
*
		PLA			; Pull off Seconds, and ignore.
		PLA			; Pull off Minutes.
		STA	MINUTES		; Store in global page.
		PLA			; Pull off Hours.
		STA	HOURS		; Store in global page.
		PLA			; Pull off Year value.
@try_again
		cmp	#100		; out of range?
		bcc	@in_range	; no, go ahead and store
		sbc	#100		; else put it back in range
		bra	@try_again
@in_range
		STA	YEAR		; Store in global page.
		PLA			; Pull off Day.
		INC	A		; Increment day value for ProDOS8 format.
		STA	DAY		; Store in global page.
		PLA			; Pull off Month.
		INC	A		; Inc month value for ProDOS8 format.
		ASL	A		; Shift month as it sits in between
		ASL	A		; the year and day values.
		ASL	A
		ASL	A
		ASL	A
		ORA	DAY		; Put all but the top bit of month value
		STA	DAY		; in the day byte.
		ROL	YEAR		; Put hi bit of mo. in lo bit of yr byte.
		PLA			; Pull off unused byte.
		PLA			; Pull off Day of Week. Stack now clean.

		SEC			; Now go back to emulation mode
		XCE			; to continue with ProDOS8.
		RTS			; That's all.

SAVESTATE	DC.B	0		;Keep the state of state register
		DC.B	'JIMJAYKERRY&MIKE'
CLOCK_END
		DS.B	(125) - (* - procstart)	; Zero rest of 125 bytes.
SIZE		EQU	*-CLOCK_BEGIN	; MUST be $7D (125) bytes in length!
	if (*-procstart)<>125 then
	aerror	'CCLock code overflow'
	endif
		END