# SkyBoot Program by arfans.id

################################## DO NOT CHANGE ANY TEXT BELOW HERE !! ##################################
################################ JANGAN MENGUBAH TULISAN APAPUN DISINI !! ################################

set color_normal=light-gray/black
set gray="set color_normal=light-gray/black"
set green="set color_normal=green/black"
set red="set color_normal=red/black"
set yellow="set color_normal=yellow/black"

# DEFINE VARIABLES FOR MBR\EFI and 32/64-bit (note: Some systems may be UEFI32+CPU64 = UEFI32 BIOS but 64-bit CPU)
set CPU64=false; set CPU32=false; set MBR=false; set EFI=false; set EFI64=false; set EFI32=false; set MBR32=false; set MBR64=false
set CPU32=true
if cpuid -l; then set CPU64=true; fi
if [ "${grub_cpu}" == "x86_64" ]; then set CPU64=true; fi
if $CPU64 == true ; then set CPU32=false ; fi
if [ "${grub_platform}" == "pc" ]; then set MBR=true; fi
if [ "${grub_platform}" == "efi" ]; then set EFI=true; fi
if [ "${grub_cpu}" == "x86_64" and $EFI = true ]; then set EFI64=true; fi
if [ "${grub_cpu}" == "i386" and $EFI = true ]; then set EFI32=true; fi
if [ $CPU64 = true and $MBR = true ]; then set MBR64=true; fi
if [ $CPU32 = true and $MBR = true ]; then set MBR32=true; fi
export MBR EFI MBR32 MBR64 EFI32 EFI64 CPU32 CPU64

# if type 0 in MBR then clear the table entry
set x=NONE
hexdump -q -s 0x1e2 -n 1 (${bootdev})0+1 x
if [ "$x" = "\x00" ] ; then partnew -t 0 -s 0 -l 0 (${bootdev}) 3; fi
set x=NONE
hexdump -q -s 0x1f2 -n 1 (${bootdev})0+1 x
if [ "$x" = "\x00" ] ; then partnew -t 0 -s 0 -l 0 (${bootdev}) 4; fi
unset x

#run .cfg and some other files immediately
grubfm_set --boot 1

#hide non-bootable files
grubfm_set --hide 0

clear

source (${user})/boot/password.asm

if [ -f (${user})/boot/theme.asm ] ; then
	source (${user})/boot/theme.asm
else
	set SkyThemes=standard
fi

if [ -f (${user})/boot/font.asm ] ; then
	source (${user})/boot/font.asm
else
	set SkyFonts=unicode
	if	[ "${SkyThemes}" = "SkyNux" ] ; then
	    loadfont ${prefix}/fonts/droid
    else
	    loadfont ${prefix}/fonts/${SkyFonts}
    fi
fi

if [ -f (${user})/boot/timeout.asm ] ; then
	source (${user})/boot/timeout.asm
else
	set timeout=100
fi

if [ -d (hd0,1)/ISO ]; then
		configfile ${prefix}/SkyThemes.sh
	else
		export theme_std="${prefix}/themes/${SkyThemes}/theme.txt";
		export theme_fm="${prefix}/themes/${SkyThemes}/theme.txt";
		export theme_info="${prefix}/themes/${SkyThemes}/theme.txt";
		export theme=${theme_std};
		grubfm;
fi