Subject:  [JForth-List] Timings
     Date: 
          Tue, 1 Sep 1998 16:45:38 +0200 (METDST)
     From: 
          Acereda Macia Jorge <al004046@alumail.uji.es>
 Reply-To: 
          JForth-List@chaossolutions.com
       To: 
          "JForth-List List Member" <JForth-List@mail.chaossolutions>

Hi,

Here you have a couple of small utilities that can be useful for those
willing to write demos and games (anyone out there?). Is it ok to post
sources in this list? Otherwise, where can we share our code?

The first is a more accurate alternative to MEASURE. It takes
advantage of LowLevel.library, so it might be useless for those
lacking this library. It can be called with multitasking off, but
remember to bring it back to life before printing :-)

The second is a frames per second counter.

If you find crappy code, please tell me... I'm new to JForth.

BTW if there's someone interested in writing demos using JForth,
please email me so we can exchange our ideas/code (and perhaps
creating the first Forth demo group ;-) Wouldn't it be a great
promotion for JForth writing a fast and cool demo? :-)

I'm also writing a demo-oriented chunky screen management system.  I
have 18 bits true-color 2x1, 2x2 and fake 1x1 (using GRGB instead of
the typical RGBB) displays almost ready. They use HiRes screens to do
the trick. I plan to add scrambled 15bits true-color and 8 bits
color-mapped displays later.

Also, has anyone interfaced rtgmaster.library with JForth? Does it
have true-color support for AGA?

If you're interested (or if I'm re-inventing the wheel) email me.

Greetings,
        Jorge

-------8<-------8<-------8<--- CRONO ----8<-------8<-------8<-------
\ Accurate time measurements
\ Jorge Acereda 30-08-98
\
\ .Crono ( -- ) Display elapsed seconds between 2 invocations of Crono
\ Crono  ( -- )

INCLUDE? FPINIT jflt:float.double
FPINIT

ANEW TASK-CRONO

:Library lowlevel

: LowLevel? ( -- )
        LowLevel_NAME LowLevel_LIB LIB?
;

: -LowLevel ( -- ) 
        LowLevel_LIB -LIB
;

CREATE Crono-Vals 0 , 0 ,
VARIABLE Crono-Time

: Crono ( -- )
        Crono-Vals CALL>ABS LowLevel_Lib ElapsedTime Crono-Time !
BOTH ;

: .Crono ( -- )
        Crono-Time @ FLOAT 65536.0 F/ F.
;

: AUTO.INIT ( -- )
        AUTO.INIT LowLevel?
;

: AUTO.TERM ( -- )
        AUTO.TERM -LowLevel
;

LowLevel?
-------8<-------8<-------8<--- FPS ----8<-------8<-------8<-------
\ Frames per second measurement
\ Jorge Acereda 30-08-98
\
\ FPS.Init  ( -- ) Start measurement
\ FPS.Count ( -- ) Call it each time you render a frame
\ .FPS      ( -- ) End measurement and display number of frames per second


INCLUDE? Interrupt ji:exec/interrupts.j
INCLUDE? FPINIT jflt:float.double
FPINIT

ANEW TASK-FPS

50 CONSTANT FREQUENCY

Interrupt FPS-Interrupt

VARIABLE FPS-Ints
ASM FPS.Server
        addq.l  #1,(a1)
        moveq   #0,d0
END-CODE

: FPS.AddIntServer ( -- )
        FPS-Ints FPS-Interrupt S! IS_Data
        ' FPS.Server FPS-Interrupt S! IS_Code
        5 FPS-Interrupt CALLVOID>ABS Exec_Lib AddIntServer
;

: FPS.RemIntServer ( -- )
        5 FPS-Interrupt CALLVOID>ABS Exec_Lib RemIntServer
;       


VARIABLE FPS-Count
: FPS.Count ( -- )
        1 FPS-Count +!
BOTH ;

: FPS.Init ( -- )
        FPS.AddIntServer FPS-Count OFF FPS-Ints OFF
;

: .FPS ( -- )
        FPS.RemIntServer 
        FPS-Count @ FREQUENCY * FLOAT FPS-Ints @ FLOAT F/ F.
;