[Oberon] Input.Timer in Native Oberon

Jörg Straube joerg.straube at iaeth.ch
Fri Jan 29 10:11:01 CET 2016


counter0 measures the time how long a cursor key is pressed with a granularity of 10 ms. The longer you keep the key pressed the faster the mouse moves. The IF limits counter0 to max 100 = 1 sec.

If you write "counter0 DIV (100 DIV 12) + 1" the interpretation is as follows:
Max speed at 1 second is 12 + 1 pixel.

If you write "counter0 DIV 8 + 1" you say:
All 80 ms the speed is increased by 1 pixel.

I would have coded this procedure as follows:

CONST
   Home = 0; UpArr = 1; PgUp = 2; LftArr = 4;
   RtArr = 6; End = 8; DnArr = 9; PgDn = 10;

IF counter1 # TimeUnit DIV 100 THEN   INC(counter1)
ELSE (* check cursor keys all 10 ms *)
   counter1 := 0;
   IF kpmap * {0..2, 4, 6, 8..10} = {} THEN counter0 := 0  (* no cursor key *)
   ELSE
      IF counter0 < 100 THEN INC(counter0) END;    (* max speed at 1 sec *)
      i := counter0 DIV (100 DIV 12) + 1;                (* max speed is 12+1 pixel *)
      IF kpmap * {Home, LftArr, End}    # {} THEN DEC(kdx, i) END;
      IF kpmap * {Home, UpArr, PgUp} # {} THEN DEC(kdy, i) END;
      IF kpmap * {PgUp, RtArr, PgDn}   # {} THEN INC(kdx, i) END;
      IF kpmap * {End, DnArr, PgDn}     # {} THEN INC(kdy, i) END
   END
END

br, Jörg

Am 28.01.2016 um 20:16 schrieb Paul Reed <paulreed at paddedcell.com>:

>>> For time interval counter0, the displacement increment is
>>>        i := counter0 DIV (100 DIV 12)+1;
>>> 
>>> Isn't 100 DIV 12 always 8?  Why not this arithmetic?
>>>        i := counter0 DIV 8+1;
>> 
>> Usually the compiler does this. The object code should be the same.
> 
> But not if it's
> 
>   i := counter0 DIV 100 * 12 + 1;
> 
> so the original "why" still stands, right? :)
> 
> Cheers,
> Paul
> 
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2376 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20160129/ce63f13d/attachment.p7s>


More information about the Oberon mailing list