;               TIM - DEMO                0
; TIMWIN Demo program 05/30/92       (c) TEA 1992
;
; The following variables are used:
; - imode
;    0     no win-images
; 1 - 4    Info for Win-images LUTs
;    16    use  16 colour win-images
;   256    use 256 colour win images 
; 0x400    use pop-up help (otherwise only @ F1)
;
;****************************************************
int choice
file timdemo = "timdemo.hlp"
int imode
int hmode = 1
int config
char message[128]
string dtext = ""
string htext = ""
char naam[8]
IMAGE winim
int imnum=0
int winattr = 0

dest p
set update 0           ;no auto updating ibuf

*testcfg 1             ;1st time to initialise FG
show p
switch (config = *testcfg 1)    ;test configuration silently
  case 0               ;if no frame grabber:
    imode = 16         ;use 16-colour Windows image
  case 6               ;if frame grabber in testconfig.
    imode = 16         ;use 16-colour Windows image
  case 15
    imode = 0          ;frame grabber available
  default
    print (*testcfg)   ;test again, print report
    pause
    goto stop
endsw

;call fmessage   

*init
*inilock
;pm:
;lcset standard
help timdemo "demo program", hmode

repeat         ;repeat until ...
 cls
 *reset
 print @8 @i "                     TIMWIN DEMO                            " @n @r
 print @18 "Choose one of the following: " @n @r
 print @8 "Stop (return to interactive mode) . . . . . . . . . . . 0" 
 print @8 "Check system setup  . . . . . . . . . . . . . . . . . . 1"
 print @8 "Define settings     . . . . . . . . . . . . . . . . . . 2" @r 
 print @8 "Free running demos  . . . . . . . . . . . . . . . . . . 3"
 print @8 "Free running floating point intensive demos . . . . . . 4"
 print @8 "Real colour display demos . . . . . . . . . . . . . . . 5"
 print @8 "Abingdon cross benchmark  . . . . . . . . . . . . . . . 6"
 print @8 "Run Demos in Debug mode . . . . . . . . . . . . . . . . 7" @r
 choice = "              Enter your choice . . . . . . . . . . . . . . .  "

 switch choice
    case 1:
      print (*testcfg 0)
      pause
    case 2:
      call getconf
    case 3:
      *dfrd imode timdemo hmode
    case 4:
      *dfrdf imode timdemo hmode
    case 5:
      *dfrdcol imode timdemo hmode
    case 6:
      *dacross imode timdemo hmode
    case 7: 
      help timdemo "debug", hmode
      debug                     ;continue in debug mode
 endsw
until choice == 0

stop:
cls
stop

getconf:
 cls

 print @8 @i "               Specify configuration                     " @n @r
 print @18 "Choose one of the following: " @n @r
 print @8 "Ready  (back to the main menu) . . . . . . . . . . . . 0" @r
 print @8 "Display on frame grabber . . . . . . . . . . . . . . . 1" 
 print @8 "Display using Windows images ( 16 colours) . . . . . . 2" 
 print @8 "Display using Windows images (256 colours) . . . . . . 3" @r
 print @8 "Help pages pop up automatically  . . . . . . . . . . . 4" 
 print @8 "Wait at new help page  . . . . . . . . . . . . . . . . 5"
 print @8 "Help pages on request (F1) only  . . . . . . . . . . . 6" @r
 choice = "                Enter your choice . . . . . . . . . . . . . . "

switch choice
  case 1
    if config != 15
      pause "You specified a frame grabber, but you haven't got one!"
    else
      imode = 0
      winattr = 0
      call showwinims
	endif
  case 2
	imode = 16
    winattr = 1
    call showwinims
  case 3
    imode = 256
    winattr = 1
    call showwinims
  case 4
    hmode = 2     ; 1024??
  case 5
    hmode = 1
  case 6
    hmode = 0
  default
    choice = 1    ;otherwise program stops
    return
endsw

;call fmessage

goto getconf


fmessage:
switch imode
  case 0
;    dtext = "FrGrabber only"
  case 16
;    dtext = "Windows (16 grv)"
  case 256
;    dtext = "Windows (256 grv)"
endsw

switch hmode
  case 1024
;    htext = "Auto help"
  case 0
;    htext = "on request"
endsw

;fprint message "Image display: %s   Help: %s\n", dtext, htext

return
 
showwinims:         ;make all (256x256 sized) windows images visible
repeat
  fprint naam 0 "%s" (getim WIN_BIT (++imnum))  ;256x256 winbeeld
  winim = naam
  if  naam[0] != 0  show winim winattr
until naam[0] == 0
winattr = 0
return

