;ApolloBoot Shared Startup-Sequence for AOS32 R91
;Willem Drijver
;25-3-2023

FailAt 21

;AB Checking ROM
ApolloMap >NIL: SYS:Devs/Kickstarts/KickA1200.ROM

;Disable SuperScalar if apollopatch-3.2.2. is not applied to ROM
;If NOT Exists DEVS:Kickstarts/A1200.47.110.ROM
  ApolloControl >NIL: SS=0
;Endif

;AB Setting Env-Archive
Makedir >NIL: RAM:ENV RAM:ENV/Sys RAM:Clipboards RAM:T
Assign >NIL: ENV: RAM:ENV
Copy >NIL: ENVARC:#? ENV: ALL

Execute >NIL: BOOT:S/ApolloBoard

Execute >NIL: BOOT:S/ApolloHostChange

If NOT $ABHOST EQ "UAE"
  Execute >NIL: BOOT:S/ApolloSettings
Endif

Assign >NIL: libs:delayed ADD
RemLib >NIL: icon.library

SetPatch QUIET

Resident C:Assign PURE


; 32se stuff
Assign >nil: EXISTS AmigaOS:
If warn
  Assign AmigaOS: SYS: DEFER
EndIf
Assign >nil: EXISTS System:
If warn
  Assign System: SYS: DEFER
EndIf
; end


Assign >NIL: ENV: RAM:ENV
Assign >NIL: CLIPS: RAM:Clipboards
Assign >NIL: T: RAM:T
Assign >NIL: REXX: S:


;boot picture
If EXISTS sys:AmigaOSse/themes/themes/$ctheme/PicBoot
type sys:AmigaOSse/Themes/Themes/$ctheme/PicBoot > env:picboot
    If $picboot EQ "1"
        If EXISTS sys:AmigaOSse/themes/themes/$ctheme/SE_boot_1.iff
            syspic.020 sys:AmigaOSse/themes/themes/$ctheme/SE_boot_1.iff NF ST
        endif
    endif
endif
;End  


Assign >NIL: PRINTERS: DEVS:Printers
Assign >NIL: KEYMAPS: DEVS:Keymaps
Assign >NIL: LOCALE: SYS:Locale
Assign >NIL: LIBS: SYS:Classes ADD
Assign >NIL: LIBS: LIBS:Delayed ADD
Assign >NIL: HELP: LOCALE:Help DEFER


; 32se stuff
Assign User: sys:storage/accounts/guest
Assign Themes: sys:AmigaOSse/Themes/Themes
Assign Apps: sys:apps
Assign 32se: RAM:T
; end


If $ABEDITION EQ "SOLO"
  Assign >NIL: Personal: SYS:Personal
  Assign >NIL: A-Demos: Personal:Demos
  Assign >NIL: A-Games: Personal:Games
Else
  Assign >NIL: A-Demos: Archives:Demos
  Assign >NIL: A-Games: Archives:Games
Endif
Assign >NIL: A-Applications: Personal:Applications
Assign >NIL: A-Audio: Personal:Audio
Assign >NIL: A-Documents: Personal:Documents
Assign >NIL: A-Downloads: Personal:Downloads
Assign >NIL: A-Pictures: Personal:Pictures
Assign >NIL: A-Sources: Personal:Sources
Assign >NIL: A-Video: Personal:Video

BindDrivers

If $ABHOST EQ "UAE"
  DEVS:Monitors/UAEGFX
Else  
  DEVS:Monitors/VampireGFX
Endif

Mount >NIL: DEVS:DosDrivers/~(#?.info)

SetEnv Language "english"
SetEnv Workbench $Workbench
SetEnv Kickstart $Kickstart
UnSet Workbench
UnSet Kickstart

AddDataTypes REFRESH QUIET


If EXISTS SYS:System/RexxMast
  SYS:System/RexxMast >NIL:
EndIF

; 32se stuff
If EXISTS Themes:$ctheme/VP
    Assign VPT: Themes:$ctheme/VP
endif
If NOT EXISTS sys:AmigaOSse/Themes/Themes/$ctheme/theme_name
      echo "AmigaOS3.2" > envarc:ctheme
      echo "1" > env:themechange
      wait 1
endif 
;end

; VisulPrefs finetune WB  
if EXISTS sys:AmigaOSse/Themes/Themes/$ctheme/twbstartup/visualprefs@7.info
    ;cpu cputype > env:cpu
    
    ;if $cpu EQ 68060 
    ;    Run > NIL: "SYS:System/VisualPrefs/VisualPrefs_060"
    ;endif
    ;if $cpu EQ 68040 
        Run > NIL: "SYS:System/VisualPrefs/VisualPrefs_040"
    ;endif
    ;if $cpu EQ 68030 
    ;    Run > NIL: "SYS:System/VisualPrefs/VisualPrefs_020_030"
    ;endif
    ;if $cpu EQ 68020 
    ;    Run > NIL: "SYS:System/VisualPrefs/VisualPrefs_020_030"
    ;endif
EndIf
;end


IPrefs


; FullPalette
if EXISTS sys:AmigaOSse/Themes/Themes/$ctheme/twbstartup/FullPalette@7.info
    FPPrefs    
EndIf
; end

; VisualPrefs
echo $cgui > ram:t/vp

wait 1
; Birdie Windows border
if EXISTS sys:AmigaOSse/Themes/Themes/$ctheme/twbstartup/Birdie.info
    type sys:AmigaOSse/Themes/Themes/$ctheme/birdie2000 > env:cbir
    If $cbir EQ "1"
        if NOT Exists Themes:$ctheme/nbpt.jpg
            Run <>NIL: sys:system/Birdie/Birdie Themes:$ctheme/bpt.jpg
        else
            Run <>NIL: sys:system/Birdie/Birdie Themes:$ctheme/bpt.jpg Themes:$ctheme/nbpt.jpg ACTIVEPATTERN
        endif    
    EndIf
    if $cbir EQ "2" 
        if NOT Exists Themes:$ctheme/nbirdiegradient
            type sys:AmigaOSse/Themes/Themes/$ctheme/birdiegradient > env:temp
            Run <>NIL: sys:system/Birdie/Birdie $temp
        else
            type sys:AmigaOSse/Themes/Themes/$ctheme/birdiegradient > env:temp
            type sys:AmigaOSse/Themes/Themes/$ctheme/nbirdiegradient > env:temp2
            Run <>NIL: sys:system/Birdie/Birdie $temp $temp2 ACTIVEPATTERN
        endif    
    endif
endif    
;end


ConClip
;ColorManager >NIL:
;NoClick

Path >NIL: RAM: C: SYS:Utilities SYS:Rexxc SYS:System S: SYS:Prefs SYS:WBStartup SYS:Tools SYS:Tools/Commodities

MakeLink RAM:Disk.info TO ENVARC:Sys/def_RAM.info SOFT

IF EXISTS S:User-Startup
  Execute S:User-Startup
EndIF


echo "1" > envarc:bootcheck

; language file
copy sys:AmigaOSse/catalogs/english/32se_lang.cat 32se:32se_lang.cat QUIET
; end


If NOT $ABNETWORK EQ "None"
  Execute S:Network-Startup
Endif

LoadWB


wait 1

if EXISTS sys:AmigaOSse/Themes/Themes/$ctheme/twbstartup/ColorPatch.info
    if $daynight EQ 1
        Run > NIL: sys:system/ColorPatch/ColorPatch
    endif    
endif


; 32se stuff
echo "0" > envarc:tcnl

type sys:AmigaOSse/Themes/Themes/$ctheme/theme_type > env:cthemetype

If $themechange EQ "1"
    execute sys:amigaosse/themes/Script/Set_Current_Theme
else
    execute sys:amigaosse/themes/Script/Theme_bicons
EndIF


If $cthemetype EQ "dual"
    echo "1" > env:daynightNG
    wait 1
    run >NIL: sys:rexxc/rx sys:amigaosse/themes/Script/DNClock > NIL:
endif
If $cthemetype EQ "big"
    run >NIL: sys:rexxc/rx sys:amigaosse/themes/Script/BIGClock > NIL:
endif
If $cthemetype EQ "rnd"
    run >NIL: sys:rexxc/rx sys:amigaosse/themes/Script/RNDClock > NIL:
endif

; magicmenu
if EXISTS sys:AmigaOSse/Themes/Themes/$ctheme/twbstartup/MagicMenu.info
    run <>NIL: sys:system/magicmenu/MagicMenu
endif


; 32se stuff
sys:rexxc/rx sys:amigaOSse/Themes/Script/run32sewbstartup
; end

If $picboot NOT EQ "0"
    WBRUN sys:system/32seStartup/ClosePic
endif

wait 2



If $ONTIME EQ "NTP"
  Execute S:Time-NTP
Endif

If $ONTIME EQ "RTC"
  Execute S:Time-RTC
Endif  


; 32se news
If Exists sys:system/32sestartup/news3 
	If Exists sys:system/32sestartup/news 
    	Delete sys:system/32sestartup/news QUIET
    endif
    Delete sys:system/32sestartup/news3 QUIET
Endif

If Exists sys:system/32sestartup/news2 
    Delete sys:system/32sestartup/news2 QUIET
	echo "1" > sys:system/32sestartup/news3
Endif

If Exists sys:system/32sestartup/news
    execute sys:system/32sestartup/news 
    wait 1 
    echo "1" > sys:system/32sestartup/news2
Endif
; end

copy c:reboot to ram:T/ QUIET
copy c:wait to ram:T/ QUIET
echo "0" > envarc:bootcheck

wait 2

; theme audio    
If Exists sys:amigaosse/themes/themes/$ctheme/audio1.wav
    run >NIL: c:play16 sys:amigaosse/themes/themes/$ctheme/audio1.wav
endif

EndCLI >NIL:
