'Blubber Dragon Quick GFX Converter
'----------------------------------
'$INCLUDE: 'DQBREL.BI'

'$DYNAMIC

'Palette
DIM SHARED Pal AS STRING * 786

ON ERROR GOTO QUIT

IF DQBinit(0, 0, 0) THEN JError$ = "Cannot load DirectQB 1.61 + DQBrel libraries!": GOTO QUIT
DQBinitVGA

'Create files
'--------------------------------------------------

OPEN "CONVERT.DAT" FOR INPUT AS #1
INPUT #1, FORMAT1$
INPUT #1, FORMAT2$
JFORMAT% = -1
IF FORMAT2$ = ".PCX" THEN JFORMAT% = 0
IF FORMAT2$ = ".BMP" THEN JFORMAT% = 1
IF FORMAT2$ = ".PUT" THEN JFORMAT% = 2
IF JFORMAT% = -1 THEN JError$ = "Can't save to unknown file format. Check CONVERT.DAT.": GOTO QUIT
INPUT #1, WAITTIME%
DO
INPUT #1, JTEMP$
LOOP UNTIL JTEMP$ = "IMAGES:"
DQBinstallKeyboard
DO
INPUT #1, JTEMP$
DQBclearLayer VIDEO
IF DQBloadImage(VIDEO, 0, 0, JTEMP$ + FORMAT1$, Pal, 0, 0) THEN JFORMAT% = 8: GOTO QUIT
DQBsetPal Pal
IF DQBsaveImage(VIDEO, 0, 0, 319, 199, JTEMP$ + FORMAT2$, Pal, JFORMAT%) THEN JFORMAT% = 9: GOTO QUIT
IF DQBkey(KEYESC) = TRUE THEN JError$ = "Aborted.": GOTO QUIT
IF WAITTIME% > 0 THEN DQBwait WAITTIME%
IF EOF(1) THEN CLOSE : JError$ = "All images converted successfully!": GOTO QUIT
LOOP

QUIT:
CLOSE
DQBclose     'close DirectQB 1.61 + DQBrel

CLS

IF JFORMAT% = 8 THEN PRINT "Error opening file: " + JTEMP$ + FORMAT1$
IF JFORMAT% = 9 THEN PRINT "Error saving file: " + JTEMP$ + FORMAT2$

IF JError$ <> "" THEN PRINT JError$
IF ERR <> 0 THEN PRINT STR$(ERR) + " - Last QB error code"
IF DQBerror$ <> "" THEN PRINT DQBerror$ + " - DirectQB message"
PRINT
PRINT "- Exited Blubber Dragon Quick GFX Converter -"
PRINT
PRINT "- Press any key to continue -"

WHILE INKEY$ = "": WEND

END

