Path: news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!howland.reston.ans.net!gatech!newsjunkie.ans.net!newsfeeds.ans.net!newstf01.news.aol.com!newsbf02.news.aol.com!not-for-mail From: rubywand@aol.com (RUBYWAND) Newsgroups: comp.sys.apple2.programmer Subject: Re: HELP - IIgs timer... Date: 16 Mar 1996 07:38:34 -0500 Organization: America Online, Inc. (1-800-827-6364) Lines: 68 Sender: root@newsbf02.news.aol.com Message-ID: <4iecoa$6d7@newsbf02.news.aol.com> References: <4ib8vg$o3d@gap.cco.caltech.edu> NNTP-Posting-Host: newsbf02.mail.aol.com X-Newsreader: AOL Offline Reader In article <4i7mgg$sse@leonard.anu.edu.au>, Kristen Maria Pammer wrote: >The program basically sets up the timer using a few "POKE" commands >then sits in a loop waiting for a specific value to appear in a certain >location, which it polls using "PEEK". The problem is that the program >just seems to hang indefinitely in this loop - the value it is waiting >for never shows up. > > What I want to know, is: is it possible that the >timer is mapped to a different memory location on my IIgs to the one that >the program originally ran on? is there any other likely cause to this >problem? You are not likely to find a hardware timer on the IIgs with the same output address(es) as one employed on a II+ or IIe. A fix is to use a Toolbox CALL which reads the IIgs clock and places the result in a memory location you specify. You can poke the code into the $0300 area (or BLOAD it). The BASIC routine could look something like 50 CALL 768: REM CALL routine which does CALL to ReadTimeHex 60 TC = PEEK(815): REM assumes routine puts Seconds at $32F 70 IF TC <> TE THEN GOTO 50: REM TE is the end/exit value you set 80 RETURN The subroutine is good for waits of up to 60 seconds. It should cycle fast enough to guarantee that the TC = TE condition will not be missed. For longer waits, line 60 might be 60 TC = 60 * PEEK(816) + PEEK(815): REM 60 x Minutes + Seconds This kind of thing starts to take time at "normal" speed. To make sure you do not miss TC = TE you will probably want the routine to avoid unnecessary delays: 50 CALL 768: IF 60 * PEEK(816) + PEEK(815) <> TE THEN 50 80 RETURN Machine code for a routine which CALLs ReadTimeHex and saves Seconds and Minutes at $32F, $330 is shown below: 300: 18 First, set Native mode with 16 bit registers 301: FB 302: C2 30 304: 48 Push 4 words of 'workspace' onto stack 305: 48 306: 48 307: 48 308: A2 03 0D Put ReadTimeHex tool ID in X 30B: 22 00 00 E1 JSR long to dispatcher to do the Read 30F: 68 Pull MinSec result word from Stack (Lo byte = Seconds) 310: 8D 2F 03 Save result word at $32F 313: 68 (YrHour) Pull other three result words to restore stack 314: 68 (MoDay) 315: 68 (WkdayNull) 316: E2 30 Restore Emulation mode with 8-bit registers 318: 38 319: FB 31A: 60 Exit back to BASIC Rubywand