Path: news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!alfa02.medio.net!netnews.nwnet.net!nntp.cac.washington.edu!news.uoregon.edu!cie-2.uoregon.edu!nparker From: nparker@cie-2.uoregon.edu (Neil Parker) Newsgroups: comp.sys.apple2.programmer Subject: Re: Reading Clock on a GS Date: 21 Mar 1995 10:39:27 GMT Organization: University of Oregon Campus Information Exchange Lines: 80 Message-ID: <3kmacv$ohq@pith.uoregon.edu> References: NNTP-Posting-Host: cie-2.uoregon.edu In article bongini@law3.law.ucla.edu (STEPHEN BONGINI) writes: > Is there a way to find out the time on a GS from BASIC. I know the >peeks to get the date & figure there are probably other locations to peek to >get the time. Does anyone know how to do this? If you're using ProDOS, and you're satisfied with having just the hours and the minutes, and you don't need the seconds, you can ask ProDOS for the time: JSR $BF00 ;Call ProDOS MLI DB $82 ;GET_TIME command DW $0000 ;no parameter list RTS This leaves the current date and time in the ProDOS global page. From BASIC, you can do it like this: 10 FOR X = 0 TO 6: READ Y: POKE 768 + X,Y: NEXT 20 DATA 32,0,191,130,0,0,96 30 CALL 768 40 HR = PEEK (49043):MN = PEEK (49042) This leaves the current hour (0-23) in HR, and the minute (0-59) in MN. If you're not in ProDOS, or if you want more than just the hour and minute, it's harder. You need to verify that you're on a GS, and if you are, call the toolbox routine _ReadTimeHex. In machine language, SEC JSR $FE1F ;IDROUTINE--test for IIGS BCC OK ;continue only if IIGS RTS OK XCE ;go native REP #$30 PHA ;push result space PHA PHA PHA LDX #$0D03 ;_ReadTimeHex JSL $E10000 SEP #$30 LDX #7 LOOP PLA ;get bytes off stack into buffer STA BUF,X DEX BPL LOOP SEC ;back to emulation mode XCE RTS BUF DS 8 ;space for result From basic: 10 X = 768 20 READ Y: IF Y > - 1 THEN POKE X,Y:X = X + 1: GOTO 20 30 DATA 56,32,31,254,144,1,96,251,194,48,72,72,72,72 40 DATA 162,3,13,34,0,0,225,226,48,162,7,104,157,128,3 50 DATA 202,16,249,56,251,96,-1 60 CALL 768 70 WD = PEEK (896): REM Weekday (1=Sun...7=Sat) 80 MO = PEEK (898): REM Month (0=Jan...11=Dec) 90 DA = PEEK (899): REM Day (0...30) 100 YR = PEEK (900): REM Year-1900 110 HR = PEEK (901): REM Hour (0...23) 120 MN = PEEK (902): REM Minute (0...59) 130 SC = PEEK (903): REM Second (0...59) If you're not running on a GS, this routine will produce garbage instead of the current date and time. - Neil Parker P.S. Warning: The above machine-language routines were assembled and converted to decimal by hand, without actually testing them on a real Apple II. Use with extreme caution. -- Neil Parker No cute ASCII art...no cute quote...no cute nparker@cie-2.uoregon.edu disclaimer...no deposit, no return... nparker@cie.uoregon.edu (This space intentionally left blank: )