[comp.sys.handhelds] HP48sx chess clock

squires@delta.eecs.nwu.edu (Matt Squires) (03/26/90)

Hello!

Here is my second HP48sx application, a chess clock.  It is odd
that I keep posting time type programs - I use my 48 mostly for
fractal research and parallelogram transformations, but those
programs don't seem like postable material.

Sorry this program is not in "downloadable" format.  I don't have
a serial kit or the manuals anywhere near me.  It should be
realtively easy to figure out what ASCII maps to what HP
character (no fancy radical signs like last time :-).

Just run CCLK, and press any key (except ON :-) to switch timers.
The chess clock will beep when a timer runs out.

Please send comments, bug fixes, complaints to
Matt Squires
squires@eecs.nwu.edu

(no text follows CCLK)

CCLK, 334.5 bytes, checksum == # BCDAh
<<
   CLLCD                              @ Setup screen
   4 FIX

   1.3 DUP "White:" "Black:" TIME     @ Setup variables (1.3 = 1 hr 30 mins)
-> mt  ot  ms       os       rt       @ My time, other's time, (HMS format)
                                      @ my string, other's string,
                                      @ real time
   <<
      DO
         os ot + 2 DISP               @ display other's time
         DO
            rt TIME HMS- mt HMS+      @ compute new my time from
            ms OVER + 1 DISP          @ realtime offset and display
            IF
               0 <                    @ Time's up?
            THEN
               ms 0 + 1 DISP          @ draw a pretty 0 time left
               440 5 BEEP             @ announce time's up
               0 WAIT DROP            @ wait for keypress
               KILL                   @ the end
            END
         UNTIL
            KEY                       @ keypress switches clocks
         END
         DROP                         @ drop keypress
         TIME                         @ remember the time
         rt OVER HMS- mt HMS+ ot      @ adjust my time, get other's time
         'mt' STO 'ot' STO            @ swap times
         ms os                        @ get the strings
         'ms' STO 'os' STO            @ swap them
         'rt' STO                     @ store the new real time from above
      UNTIL
         0                            @ repeat until hell freezes over
      END
   >>
>>