\ elfcolor

needs double
needs color
needs ids

2variable romversion
: os>=3.5?  ( -- flag )
    romversion >abs
    1                 \ sysFtrNumROMVersion
    [id] psys   \ sysFtrCreator
    FtrGet if
        false
    else
        romversion 2@
        (hex) 03503000. d< 0=
    then ;

variable save-enableColor
2variable save-bitDepth
variable scr-saved
0 scr-saved !

: save-screen-settings  ( -- )
    os>=3.5? if
        save-enableColor >abs
        save-bitDepth >abs
        0.                \ height - unused
        0.                \ width - unused
        DisplayModeGet >byte
        ScrDisplayMode 0= scr-saved ! 
    then ;

: restore-screen-settings  ( -- )
    scr-saved @  os>=3.5? and  if
        save-enableColor >abs
        save-bitDepth >abs
        0.                \ height - unused
        0.                \ width - unused
        DisplayModeSet >byte
        ScrDisplayMode drop
    then ;    

2variable supt-depth
: supports-8bit?  ( -- flag )
    os>=3.5? 0= if   false exit   then
    0.
    supt-depth >abs
    0.                \ height - unused
    0.                \ width - unused
    DisplayModeGetSupportedDepths
    >byte
    ScrDisplayMode  0=  ( successflag )
    supt-depth 2@ drop  (hex) 80 and
    and ;

variable set-enableColor
-1 set-enableColor !
2variable set-bitDepth
8. set-bitDepth 2!
: set-screen-depth  ( -- )
    supports-8bit?  os>=3.5? and  if
        8 ['] color-depth catch 
        if drop then
    then ;

: foreground  ( d. -- )
    os>=3.5? if
        foreground
    else
        2drop
    then ;

