/*rx*/

/* $VER: Stu's CDXL GUI v1.
*/
/*       Stu's CDXL GUI v1.3          */
/*   By Stuart Tomlinson              */
/*    casper@tomonet.demon.co.uk      */
/* http://metro.turnpike.net/~stu/    */
/*                                    */
/* Copyright  1995 Stuart Tomlinson  */
/* This is not to be modified or      */
/*  altered in anyway.                */
/*                                    */
/* There is no longer any reason to   */
/* edit ANYTHING in this file or the  */
/* accompanying StusCDXLGUI.dosbit    */
/* as there are seperate config and   */
/* catalog files in S: editable from  */
/* within the RUNNING program itself. */

if ~ exists("libs:rexxreqtools.library") then do
say "Fatel Error: Can't find rexxreqtools.library"
exit
end

if ~ exists("libs:reqtools.library") then do
say "Fatel Error: Can't find reqtools.library"
exit
end

if ~ exists("s:StusCDXLGUI.catalogue") then do
address command 'echo "" >s:StusCDXLGUI.catalogue'
end

if ~ exists("s:StusCDXLGUI.config") then do
address command 'echo "call START" >s:StusCDXLGUI.config'
end

addlib('rexxreqtools.library',0,-30)

TAGS = 'rt_reqpos=reqpos_centerwin'
TITLE = 'Stu`s CDXL GUI v1.3BETA Copyright  Stuart Tomlinson (casper@tomonet.demon.co.uk)'
STAG = ''
CTAG = 'rtez_flags=ezreqf_centertext'
NL = '0a'x

if ~ exists("StusCDXLGUI.dosbit") then do
 call rtezrequest('Missing StusCDXLGUI.dosbit!' NL 'Either that or you loaded it from CLI' NL 'and not CD`d to the program`s directory!','Eeek!',TITLE,STAG,)
 exit
end

if ~ exists("T:StusCDXLGUI.temp") then do
address command 'c:join StusCDXLGUI S:StusCDXLGUI.catalogue S:StusCDXLGUI.config to T:StusCDXLGUI.temp'
"wait 10"
address command 'rx T:StusCDXLGUI.temp'
exit
end

FTOTAL = '0'
BTOTAL = '0'
RESET = '0'
FILENAME = 'None'
BACKDROP = 'None'
X = 'Default'
Y = 'Default'
F1 = 'None'
F2 = 'None'
F3 = 'None'
F4 = 'None'
F5 = 'None'
F6 = 'None'
F7 = 'None'
F8 = 'None'
F9 = 'None'
F10 = 'None'
S1 = 'No'
S2 = 'No'
S3 = 'No'
S4 = 'No'
S5 = 'No'
S6 = 'No'
S7 = 'No'
S8 = 'No'
S9 = 'No'
S10 = 'No'
B1 = 'None'
B2 = 'None'
B3 = 'None'
B4 = 'None'
B5 = 'None'
B6 = 'None'
B7 = 'None'
B8 = 'None'
B9 = 'None'
B10 = 'None'
X1 = 'Default'
X2 = 'Default'
X3 = 'Default'
X4 = 'Default'
X5 = 'Default'
X6 = 'Default'
X7 = 'Default'
X8 = 'Default'
X9 = 'Default'
X10 = 'Default'
Y1 = 'Default'
Y2 = 'Default'
Y3 = 'Default'
Y4 = 'Default'
Y5 = 'Default'
Y6 = 'Default'
Y7 = 'Default'
Y8 = 'Default'
Y9 = 'Default'
Y10 = 'Default'


CC = 'ON'
SPEED = 'NORMAL'
LACE = 'OFF'
RES = 'LOW'
BOX = 'OFF'
STRETCH = 'OFF'
TV = 'PAL'
POINTER = 'ON'
ENDDELAY = '0'
LOOP = '1'
ABORT = 'FIRE'
CDROM = 'CD32'
SFILE = ''
SCRIPT = 'OFF'
QUITING = '0'

call CONFIG
START:

TIME = 'times'
if LOOP = '1' then TIME = 'time'
FRAMES = 'frames'
if ENDDELAY = '1' then FRAMES = 'frame'

call rtezrequest("Current settings:" NL,
"1. Colour Correction = "CC NL,
"2. Speed = "SPEED NL,
"3. Interlace = "LACE NL,
"4. Resolution = "RES NL,
"5. Box = "BOX NL,
"6. Stretched = "STRETCH NL,
"7. Screenmode = "TV NL,
"8. Pointer = "POINTER NL,
"9. End Delay = "ENDDELAY FRAMES NL,
"10. Loop = "LOOP TIME NL,
"11. Button to Abort = "ABORT NL,
"12. CD-Rom Drive Type = "CDROM NL,
,"_Go|_1|_2|_3|_4|_5|_6|_7|_8|_9|1_0|11|12|_Disk|_Other|_Quit",TITLE,STAG,)

   if rtresult = 2 & CC = 'ON' then do
    CC = 'OFF'
    call START
   end
   if rtresult = 2 & CC = 'OFF' then do
    CC = 'ON'
    call START
   end

   if rtresult = 3 & SPEED = 'NORMAL' then do
    SPEED = 'SLOW'
    call START
   end
   if rtresult = 3 & SPEED = 'SLOW' then do
    SPEED = 'NORMAL'
    call START
   end

   if rtresult = 4 & LACE = 'ON' then do
    LACE = 'OFF'
    call START
   end
   if rtresult = 4 & LACE = 'OFF' then do
    if STRETCH = 'ON' then do
     call rtezrequest('You cannot have it in Interlace with Stretch ON','They cancel each other out',TITLE,STAG,)
     call START
    end
    LACE = 'ON'
    call START
   end

  if rtresult = 5 & RES = 'HIGH' then do
    RES = 'LOW'
    call START
   end
   if rtresult = 5 & RES = 'LOW' then do
    if BACKDROP = 'None' then do
     call rtezrequest('You cannot have it in High Resolution without a backdrop.','Sorry',TITLE,STAG,)
     call START
    end
    RES = 'HIGH'
    call START
   end

  if rtresult = 6 & BOX = 'ON' then do
    BOX = 'OFF'
    call START
   end
   if rtresult = 6 & BOX = 'OFF' then do
    BOX = 'ON'
    call START
   end

  if rtresult = 7 & STRETCH = 'ON' then do
    STRETCH = 'OFF'
    call START
   end
   if rtresult = 7 & STRETCH = 'OFF' then do
    if LACE = 'ON' then do
     call rtezrequest('You cannot have it Stretched with Interlacen ON','They cancel each other out!',TITLE,STAG,)
     call START
    end

    STRETCH = 'ON'
    call START
   end

  if rtresult = 8 & TV = 'PAL' then do
    TV = 'NTSC'
    call START
   end
   if rtresult = 8 & TV = 'NTSC' then do
    TV = 'PAL'
    call START
   end

  if rtresult = 9 & POINTER = 'ON' then do
    POINTER = 'OFF'
    call START
   end
   if rtresult = 9 & POINTER = 'OFF' then do
    POINTER = 'ON'
    call START
   end

  if rtresult = 10 then do
   ENDDELAY = rtgetstring(ENDDELAY,'Enter the delay in frames at the end of the clip before it quits:' NL 'PAL = 50 frames a second' NL 'NTSC = 60 frames a second',TITLE,'_OK|_Cancel',STAG,)
   call START
   end

  if rtresult = 11 then do
  LOOP = rtgetstring(LOOP,'Enter the amount of times you want it to play (0 is for infinity):',TITLE,'_OK|_Cancel',STAG,)
  call START
  end

  if rtresult = 12 & ABORT = 'FIRE' then do
    ABORT = 'LMB'
    call START
   end
   if rtresult = 12 & ABORT = 'LMB' then do
    ABORT = 'RMB'
    call START
   end
  if rtresult = 12 & ABORT = 'RMB' then do
    ABORT = 'OFF'
    call START
   end
   if rtresult = 12 & ABORT = 'OFF' then do
    ABORT = 'FIRE'
    call START
   end

   if rtresult = 13 & CDROM = 'CD32' then do
    CDROM = 'OTHER'
    call START
   end
   if rtresult = 13 & CDROM = 'OTHER' then do
    CDROM = 'CD32'
    call START
   end

   if rtresult = 14 then do
    rtresult = ''
    call rtezrequest('Do you want to save current as configuration to use on startup,' NL 'put default configuration to be used on startup,' NL 'or erase the catalogue?','_Save Current|Revert to _Defaults|_Erase Catalogue|_Cancel',TITLE,STAG,)
    if rtresult = 1 then do
     address command 'StusCDXLGUI.dosbit config' FILENAME BACKDROP CDROM X Y CC SPEED LACE RES BOX STRETCH TV POINTER ENDDELAY LOOP ABORT
    end
    if rtresult = 2 then address command 'delete S:StusCDXLGUI.config quiet'

    if rtresult = 3 then do
     call rtezrequest('Do you really, really want to do this?','_No|_Dunno|Positive|_Hmm|Not _Sure',TITLE,STAG,)
     if rtresult = 3 then address command 'delete S:StusCDXLGUI.catalogue quiet'
    end
   call START
   end

   if rtresult = 15 then call OTHER

   if rtresult = 0 then do
   call QUIT
   end
   if rtresult = 1 then do
   call PLAY
   end

call QUIT

OTHER:
if SCRIPT = 'OFF' then SCRIPTMENU = 'OFF'
if SCRIPT = 'ON' then SCRIPTMENU = 'ON ('SFILE')'
call rtezrequest('Physical Settings:' NL,
'Filename  = 'FILENAME NL,
'Backdrop = 'BACKDROP NL,
'Position = (' X ',' Y ')'NL,
'Script Writing = 'SCRIPTMENU NL,
,'_Go|_Filename|_Backdrop|_X Position|_Y Position|_Add Filename|A_dd Backdrop|_Script|_Other',TITLE,STAG,)

if BACKDROP = 'None' then RES = 'LOW'

if rtresult = 1 then do
 call PLAY
end

if rtresult = 2 then do
 call rtezrequest('Current CDXL files stored:' NL,
'1.' F1 NL,
'2.' F2 NL,
'3.' F3 NL,
'4.' F4 NL,
'5.' F5 NL,
'6.' F6 NL,
'7.' F7 NL,
'8.' F8 NL,
'9.' F9 NL,
'10.' F10,'_New|_1|_2|_3|_4|_5|_6|_7|_8|_9|1_0|_Cancel',TITLE,STAG,)

if rtresult = 1 then do
 if FILENAME = 'None' then FILENAME = ''
 BACKUP = FILENAME
 FILELOOP:
 FILENAME = rtgetstring(FILENAME,'Please enter filename and path of CDXL file (please use proper disk name, not CD0):',TITLE,'_OK|_Cancel',STAG,)
 if rtresult = 0 then FILENAME = BACKUP
 if FILENAME = '' then FILENAME = 'None'
 if FILENAME = 'None' then call OTHER

 if ~ exists( FILENAME ) then do
  call rtezrequest('File does not exist','Hang on, let me change it',TITLE,STAG,)
  call FILELOOP
 end

 call OTHER
end
if rtresult = 0 then call OTHER
if rtresult = 2 then do
 FILENAME = F1 ; STRETCH = S1
end
if rtresult = 3 then do
FILENAME = F2 ; STRETCH = S2
end
if rtresult = 4 then do
FILENAME = F3 ; STRETCH = S3
end
if rtresult = 5 then do
FILENAME = F4 ; STRETCH = S4
end
if rtresult = 6 then do
FILENAME = F5 ; STRETCH = S5
end
if rtresult = 7 then do
FILENAME = F6 ; STRETCH = S6
end
if rtresult = 8 then do
FILENAME = F7 ; STRETCH = S7
end
if rtresult = 9 then do
FILENAME = F8 ; STRETCH = S8
end
if rtresult = 10 then do
FILENAME = F9 ; STRETCH = S9
end
if rtresult = 11 then do
FILENAME = F10 ; STRETCH = S10
end
call OTHER
end

if rtresult = 3 then do
 call rtezrequest('Current backdrop files stored:' NL,
'1.' B1 NL,
'2.' B2 NL,
'3.' B3 NL,
'4.' B4 NL,
'5.' B5 NL,
'6.' B6 NL,
'7.' B7 NL,
'8.' B8 NL,
'9.' B9 NL,
'10.' F10,'_New|_1|_2|_3|_4|_5|_6|_7|_8|_9|1_0|_Cancel',TITLE,STAG,)

if rtresult = 1 then do
 BACKUP = BACKDROP
 if BACKDROP = 'None' then BACKDROP = ''
 BACKLOOP:
 BACKDROP = rtgetstring(BACKDROP,'Please enter filename and path of IFF backdrop file (please place these at a location' NL,
 'that is accessable no matter what CD is in the drive, eg. On HD):',TITLE,'_OK|_Cancel',STAG,)
 if rtresult = 0 then BACKDROP = BACKUP
 if BACKDROP = '' then BACKDROP = 'None'
 if BACKDROP = 'None' then call OTHER
  if ~ exists( FILENAME ) then do
  call rtezrequest('Backdrop does not exist','Hang on, let me change it',TITLE,STAG,)
  call BACKLOOP
 end

 call OTHER
end
if rtresult = 0 then call OTHER

if rtresult = 2 then do
BACKDROP = B1 ; X = X1 ; Y = Y1 ; BOX = BOX1
end

if rtresult = 3 then do
BACKDROP = B2 ; X = X2 ; Y = Y2 ; BOX = BOX2
end

if rtresult = 4 then do
BACKDROP = B3 ; X = X3 ; Y = Y3 ; BOX = BOX3
end

if rtresult = 5 then do
BACKDROP = B4 ; X = X4 ; Y = Y4 ; BOX = BOX4
end

if rtresult = 6 then do
BACKDROP = B5 ; X = X5 ; Y = Y5 ; BOX = BOX5
end

if rtresult = 7 then do
BACKDROP = B6 ; X = X6 ; Y = Y6 ; BOX = BOX6
end

if rtresult = 8 then do
BACKDROP = B7 ; X = X7 ; Y = Y7 ; BOX = BOX7
end

if rtresult = 9 then do
BACKDROP = B8 ; X = X8 ; Y = Y8 ; BOX = BOX8
end

if rtresult = 10 then do
BACKDROP = B0 ; X = X9 ; Y = Y9 ; BOX = BOX9
end

if rtresult = 11 then do
BACKDROP = B10 ; X = X10 ; Y = Y10 ; BOX = BOX10
end

end


if rtresult = 4 then do
 BACKUP = X
 if X = 'Default' then X = ''
 X = rtgetstring(X,'Please enter new X coordinate:',TITLE,'_OK|_Cancel',STAG,)
 if rtresult = 0 then X = BACKUP
 if X = '' then X = 'Default'
end

if rtresult = 5 then do
 BACKUP = Y
 if Y = 'Default' then Y = ''
 Y = rtgetstring(Y,'Please enter new Y coordinate:',TITLE,'_OK|_Cancel',STAG,)
 if rtresult = 0 then Y = BACKUP
 if Y = '' then Y = 'Default'
end

if rtresult = 6 then do

if FTOTAL = 10 then do
call rtezrequest('This version does not allow more then 10 filenames to be added. :(' NL,
'This should be fixed in a later version.','I cannot wait!',TITLE,STAG,)
call OTHER
end

if FILENAME = 'None' then do
 call rtezrequest('Add what filename? I cannot see a filename there.','Whoops!',TITLE,STAG,)
 call OTHER
end

call rtezrequest('Are you sure you want to add' NL FILENAME '?' NL 'It also saves stretched variable with it.','_Yes|_No',TITLE,STAG,)
 if rtresult = 0 then call OTHER
  FTOTAL = FTOTAL + 1
  address command 'execute StusCDXLGUI.dosbit file' FILENAME FTOTAL STRETCH '0 0 0 0 0 0 0 0 0 0 0 0 0'

  if FTOTAL = 1 then do
   F1 = FILENAME
   S1 = STRETCH
  end

  if FTOTAL = 2 then do
   F2 = FILENAME
   S2 = STRETCH
  end

  if FTOTAL = 3 then do
   F3 = FILENAME
   S3 = STRETCH
  end

  if FTOTAL = 4 then do
   F4 = FILENAME
   S4 = STRETCH
  end

  if FTOTAL = 5 then do
   F5 = FILENAME
   S5 = STRETCH
  end

  if FTOTAL = 6 then do
   F6 = FILENAME
   S6 = STRETCH
  end

  if FTOTAL = 7 then do
   F7 = FILENAME
   S7 = STRETCH
  end

  if FTOTAL = 8 then do
   F8 = FILENAME
   S8 = STRETCH
  end

  if FTOTAL = 9 then do
   F9 = FILENAME
   S9 = STRETCH
  end

  if FTOTAL = 10 then do
   F10 = FILENAME
   S10 = STRETCH
  end


  call OTHER
end

if rtresult = 7 then do

if BTOTAL = 10 then do
call rtezrequest('This version does not allow more then 10 backdrops to be added. :(' NL,
'This should be fixed in a later version','Ah well.',TITLE,STAG,)
call OTHER
end

if BACKDROP = 'None' then do
 call rtezrequest('Add what backdrop? I cannot see a backdrop there.','Whoops!',TITLE,STAG,)
 call OTHER
end

 call rtezrequest('Are you sure you want to add' NL BACKDROP '?' NL 'It also saves position variable with it.','_Yes|_No',TITLE,STAG,)
 if rtresult = 0 then call OTHER
  BTOTAL = BTOTAL + 1
  address command 'execute StusCDXLGUI.dosbit back' BACKDROP BTOTAL BOX X Y '0 0 0 0 0 0 0 0 0 0 0'

if BTOTAL = 1 then do
 B1 = BACKDROP
 X1 = X
 Y1 = Y
 BOX1 = BOX
end

if BTOTAL = 2 then do
 B2 = BACKDROP
 X2 = X
 Y2 = Y
 BOX2 = BOX
end

if BTOTAL = 3 then do
 B3 = BACKDROP
 X3 = X
 Y3 = Y
 BOX3 = BOX
end

if BTOTAL = 4 then do
 B4 = BACKDROP
 X4 = X
 Y4 = Y
 BOX4 = BOX
end

if BTOTAL = 5 then do
 B5 = BACKDROP
 X5 = X
 Y5 = Y
 BOX5 = BOX
end

if BTOTAL = 6 then do
 B6 = BACKDROP
 X6 = X
 Y6 = Y
 BOX6 = BOX
end

if BTOTAL = 7 then do
 B7 = BACKDROP
 X7 = X
 Y7 = Y
 BOX7 = BOX
end

if BTOTAL = 8 then do
 B8 = BACKDROP
 X8 = X
 Y8 = Y
 BOX8 = BOX
end

if BTOTAL = 9 then do
 B9 = BACKDROP
 X9 = X
 Y9 = Y
 BOX9 = BOX
end

if BTOTAL = 10 then do
 B10 = BACKDROP
 X10 = X
 Y10 = Y
 BOX10 = BOX
end

 call OTHER
end

if rtresult = 8 then do
 if SCRIPT = 'OFF' then do
  SFILE = rtgetstring(SFILE,'Please enter path and filename of script file to create/add to:',TITLE,'_OK|_Cancel',STAG,)
 if SFILE = '' then call OTHER
 if ~ exists(SFILE) then do
  call rtezrequest('Create file and start script mode?','_Yup|_Mistake!',TITLE,STAG,)
  if rtresult = 0 then call OTHER
 end
 if exists(SFILE) then do
  call rtezrequest('File exists! Append and start script mode?','_Yup|_Mistake!',TITLE,STAG,)
  if rtresult = 0 then call OTHER
 end
  address command 'echo "; AmigaDOS CDXL Playing Script. Created by" >>'SFILE
  address command 'echo "; 'TITLE'" >>'SFILE
  address command 'echo ";" >>'SFILE
  SCRIPT = 'ON'
  call OTHER
 end
 if SCRIPT = 'ON' then do
  call rtezrequest('Really want to end script?','_Yup|_Whoops!',TITLE,STAG,)
   if rtresult = 0 then call OTHER
  call rtezrequest('Install loop at end? (so the script restarts)','_Let it go on and on|_No, just once thanks',TITLE,STAG,)
   if rtezrequest = 1 then address command 'echo "execute 'SFILE'" >>'SFILE
  address command 'echo "; end" >>'SFILE
  address command 'protect' SFILE 'SWRD'
  call rtezrequest('Complete','_Good.',TITLE,STAG,)
  SCRIPT = 'OFF'
 call OTHER
 end
end

if rtresult = 0 then call START

call OTHER

PLAY:

if FILENAME = 'None' then do
 call rtezrequest('You need to specify a CDXL filename','_Eek, forgot! Okay.',TITLE,STAG,)
 call OTHER
end

if CC = 'ON' then ONE = 'MULTIPAL'
if CC = 'OFF' then ONE = ''
if SPEED = 'NORMAL' then TWO = 'XLSPEED=150'
if SPEED = 'SLOW' then TWO = ''
if LACE = 'OFF' then THREE = ''
if LACE = 'ON' then THREE = 'LACE'
if RES = 'LOW' then FOUR = 'LORES'
if RES = 'HIGH' then FOUR = 'HIRES'

if BOX = 'ON' then FIVE = 'BOXIT'
if BOX = 'OFF' then FIVE = ''
if STRETCH = 'ON' then SIX = 'SDBL'
if STRETCH = 'OFF' then SIX = ''
SEVEN = "LOOP="LOOP
if POINTER = 'ON' then EIGHT = ''
if POINTER = 'OFF' then EIGHT = 'NOPOINTER'
NINE = TV
TEN = "ENDDELAY="ENDDELAY
if ABORT = 'OFF' then ELEVEN = ''
if ABORT = 'FIRE' then ELEVEN = 'FIREABORT'
if ABORT = 'LMB' then ELEVEN = 'LMBABORT'
if ABORT = 'RMB' then ELEVEN = 'RMBABORT'
THIRTEEN = 'BACK'
if BACKDROP = 'None' then BACKDROP = ''
if BACKDROP = '' then THIRTEEN = ''
FOURTEEN = 'X'
if X = 'Default' then X = ''
if X = '' then FOURTEEN = ''
FIFTEEN = 'Y'
if Y = 'Default' then Y = ''
if Y = '' then FIFTEEN = ''
if CDROM = 'CD32' then SIXTEEN = 'CDXL'
if CDROM = 'OTHER' then SIXTEEN = 'DOSXL'
if SCRIPT = 'ON' then do
 address command 'echo "cdgsxl.new' FILENAME THIRTEEN BACKDROP FOURTEEN X FIFTEEN Y ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN SIXTEEN' " >>'SFILE
 call rtezrequest('The command and configuration have been added to the script.','Next one then?',TITLE,STAG,)
end
if SCRIPT = 'OFF' then do
 address command 'cdgsxl.new' FILENAME THIRTEEN BACKDROP FOURTEEN X FIFTEEN Y ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN SIXTEEN
end
if BACKDROP = '' then BACKDROP = 'None'
if X = '' then X = 'Default'
if Y = '' then Y = 'Default'

call START

QUIT:
if SCRIPT = 'ON' then do
 call rtezrequest('Script still running!','_Eek, forgot! Okay.',TITLE,STAG,)
 call START
end

address command 'delete t:StusCDXLGUI.temp quiet'
exit

CONFIG:

