/*
 * Render_Foreign.ifx.pre
 * Written by Thomas Krehbiel
 *
 * Render to a Foreign display format.
 *
 * Inputs:
 *    Word(Arg(1),1) = Sequence number
 *    Word(Arg(1),2) = Total number of frames (N)
 *
 * Returns:
 *    0 if successful, non-zero on failure
 *
 */

OPTIONS RESULTS

base = 'Autofx_RendForeign_'

dithtype = GETCLIP(base||'DithType')
dithdir  = GETCLIP(base||'DithDir')
ditherr  = GETCLIP(base||'DithErr')
colors   = GETCLIP(base||'Colors')
monitor  = GETCLIP(base||'Monitor')
horiz    = GETCLIP(base||'Horiz')
vert     = GETCLIP(base||'Vert')
lockpal  = GETCLIP(base||'LockPal')

IF dithtype = "" THEN dithtype = 1
IF dithdir  = "" THEN dithdir  = 2
IF ditherr  = "" THEN ditherr  = 0
IF colors   = "" THEN colors   = 7
IF monitor  = "" THEN monitor  = 0
IF horiz    = "" THEN horiz    = 1
IF vert     = "" THEN vert     = 1
IF lockpal  = "" THEN lockpal  = 0

Gadget.1 = 'CYCLE 100  5 90 12 "Dither:"' dithtype '"None/Floyd/FloydR/EDD/Order"'
Gadget.2 = 'CYCLE 200  5 90 12 " "' dithdir '"L-to-R/R-to-L/ZigZag"'
Gadget.3 = 'CYCLE 300  5 90 12 " "' ditherr '"None/Low/Medium/High"'
Gadget.4 = 'CYCLE 300 20 90 12 "Colors:"' colors '"2/4/8/16/32/64/128/256/HAM/HAM8"'
Gadget.5 = 'CYCLE 100 34 90 12 "Mode:"' monitor '"Default/NTSC/PAL/VGA/Euro36/Euro72/Super72/DBLNTSC/DBLPAL"'
Gadget.6 = 'CYCLE 200 34 90 12 " "' horiz '"Lores/Hires/S-Hires"'
Gadget.7 = 'CYCLE 300 34 90 12 " "' vert '"No Lace/Lace"'
Gadget.8 = 'CHECK 100 50 26 11 "Lock Palette?"' lockpal
Gadget.9 = 'END'

NewComplexRequest '"Foreign Render Module Settings"' Gadget 410 68
IF rc ~= 0 THEN EXIT rc

dithtype = result.1
dithdir  = result.2
ditherr  = result.3
colors   = result.4
monitor  = result.5
horiz    = result.6
vert     = result.7
lockpal  = result.8

colorarray.0 = 2
colorarray.1 = 4
colorarray.2 = 8
colorarray.3 = 16
colorarray.4 = 32
colorarray.5 = 64
colorarray.6 = 128
colorarray.7 = 256
colorarray.8 = 'HAM'
colorarray.9 = 'HAM8'

monarray.0 = 'DEFAULT'
monarray.1 = 'NTSC'
monarray.2 = 'PAL'
monarray.3 = 'VGA'
monarray.4 = 'EURO36'
monarray.5 = 'EURO72'
monarray.6 = 'SUPER72'
monarray.7 = 'DBLNTSC'
monarray.8 = 'DBLPAL'

horzarray.0 = 'LORES'
horzarray.1 = 'HIRES'
horzarray.2 = 'SUPERHI'

vertarray.0 = 'NOLACE'
vertarray.1 = 'LACE'

SetRender Foreign
IF rc ~= 0 THEN EXIT rc

Render 'Colors' colorarray.colors
Render 'Dither' dithtype dithdir ditherr
Render 'Monitor' monarray.monitor
Render 'Mode' horzarray.horiz vertarray.vert

CALL SETCLIP(base||'DithType', dithtype)
CALL SETCLIP(base||'DithDir', dithdir)
CALL SETCLIP(base||'DithErr', ditherr)
CALL SETCLIP(base||'Colors', colors)
CALL SETCLIP(base||'Monitor', monitor)
CALL SETCLIP(base||'Horiz', horiz)
CALL SETCLIP(base||'Vert', vert)
CALL SETCLIP(base||'LockPal', lockpal)

EXIT
