\ FORTH - Script generated by BootCreator 1.1 (16.01.2005) 
\
\ terminal control stuff
\
: TTY.CSI d# 27 EMIT ASCII [ EMIT ;
: TTY.HOME    TTY.CSI ASCII H EMIT ;
: TTY.CLR_EOS TTY.CSI ASCII J EMIT ;
: TTY.HOME_CLR TTY.HOME TTY.CLR_EOS ;
\
\ boot menu stuff
\
: my-max-boot-num 6 ;
: my-boot-default 1 ;
: my-boot-delay d# 300 ; \ unit = 100 ms
: my-print-menu ( -- )
  TTY.HOME_CLR
  ."  " cr

  ." Gentoo 2006.0 PowerPC InstallCD" cr
  ." -------------------------------" cr
  ."  " cr
  ." Welcome to the Gentoo Linux 2006.0 PowerPC InstallCD." cr
  ."  " cr
  ." Available options:" cr
  ."  1: Linux 2.6.15 with radeonfb 1024x768 75Hz" cr
  ."  2: Linux 2.6.15 with radeonfb 1024x768 60Hz" cr
  ."  3: Linux 2.6.15 with radeonfb 1280x1024 75Hz" cr
  ."  4: Linux 2.6.15 with radeonfb 800x600 60Hz" cr
  ."  5: Linux 2.6.15 without framebuffer" cr
  ."  6: Back to SmartFirmware" cr
  ."  " cr
  ." For detailed information about this LiveCD, consult the Gentoo Handbook." cr
  ." http://www.gentoo.org/" cr
  ."  " cr
;
: my-boot-case ( num -- )
  ."  " cr
  case
    1 of " cd boot/pegasos console=ttyS0,115200 console=tty0 init=/linuxrc looptype=squashfs loop=/image.squashfs udev nodevfs cdroot root=/dev/ram0 video=radeonfb:1024x768-16@75 quiet" endof
    2 of " cd boot/pegasos console=ttyS0,115200 console=tty0 init=/linuxrc looptype=squashfs loop=/image.squashfs udev nodevfs cdroot root=/dev/ram0 video=radeonfb:1024x768-16@60 quiet" endof
    3 of " cd boot/pegasos console=ttyS0,115200 console=tty0 init=/linuxrc looptype=squashfs loop=/image.squashfs udev nodevfs cdroot root=/dev/ram0 video=radeonfb:1280x1024-16@75 quiet" endof
    4 of " cd boot/pegasos console=ttyS0,115200 console=tty0 init=/linuxrc looptype=squashfs loop=/image.squashfs udev nodevfs cdroot root=/dev/ram0 video=radeonfb:800x600-16@60 quiet" endof
    5 of " cd boot/pegasos console=ttyS0,115200 console=tty0 init=/linuxrc looptype=squashfs loop=/image.squashfs udev nodevfs cdroot root=/dev/ram0" endof
    6 of " none" endof
  endcase
  $boot
;
: my-input-num ( wait-period max-boot-num default-num -- boot-num )
  1 \ loop-inc = 1
  3 pick 0 do
    0d emit
    ." press 1-"
    ( wait-period max-boot-num default-num loop-inc )
    2 pick ascii 0 + emit
    dup 1 = if
      ."  within "
      3 pick i - d# 10 / .d
      ."  seconds"
    then
    ."  (default: "
    over ascii 0 + emit
    ." ) :                   "
    d# 100 ms
    key? if
       key
       ( wait-period max-boot-num default-num loop-inc key )
       dup 0d = if \ return pressed
         drop leave
       then

       ascii 0 -
       ( wait-period max-boot-num default-num loop-inc num )
       dup 1 5 pick
       ( wait-period max-boot-num default-num loop-inc num num 1 max-boot-num )
       between if
         rot drop swap leave
       then

       ( wait-period max-boot-num default-num loop-inc num )
       2drop 0  \ loop-inc = 0
    then
  dup +loop
  drop
  ( wait-period max-boot-num boot-num )
  nip nip
;

my-print-menu
my-boot-delay my-max-boot-num my-boot-default my-input-num
my-boot-case
