RE: Tezro Demos?
Does anyone know how to get the Onyx2 demos to work on a Tezro with V12 graphics?
All they seem to accept is Onyx2 reality graphics!
Here's the code for "Check":
Code: #!/usr/sbin/perl
###
# Designed to be called from a RUN script beginning like this:
#
# #!/bin/csh -ef
#
# if ($?H_DEMOROOT == "0") then
# setenv H_DEMOROOT /usr/demos
# endif
#
# eval `$H_DEMOROOT/Demo_Interfaces/Portalis/bin/CHECK $0 $argv`
#
# #### OVERRIDE GAMMA VALUE HERE
# $H_DEMOROOT/Demo_Interfaces/Portalis/bin/gamma.all 1.7
#
###
# ... and ending like this:
#
# $H_DEMOROOT/Demo_Interfaces/Portalis/bin/gamma.all $orig_gamma
#
# echo "Normal exit"
# exit
#
###
sub die_exit {
print STDERR "@_";
# print STDERR "\n\tHit enter to continue.\n";
# getc();
print ";exit 1\n";
exit;
}
sub goto_exit {
# print STDERR "\nHit enter to continue.\n";
# getc();
print ";exit 1\n";
exit;
}
###
# data structure notes
#
# $option_cat_entries [0 .. $#option_cat_entries] -> (category) $cat
#
# $option_entries { $cat } [0 .. $num_option_entries{ $cat }][0] -> member
# $option_entries { $cat } [0 .. $num_option_entries{ $cat }][1] -> name
# $option_entries { $cat } [0 .. $num_option_entries{ $cat }][2] -> option
# $option_entries { $cat } [0 .. $num_option_entries{ $cat }][3] -> example
# $option_entries { $cat } [0 .. $num_option_entries{ $cat }][4] -> variables
#
# $need_entries { $cat } [0 .. $num_need_entries{ $cat }][0] -> member
# $need_entries { $cat } [0 .. $num_need_entries{ $cat }][1] -> name
#
# 0 .. $num_option_entries{ $cat } -> $i - number of members in a a category
#
# $num_submember_entries{ $cat . " " $i } - number of identical members
# (eg. multiple flyboxes)
#
# $config_entries { $cat } [0 .. $num_submember_entries{ $cat }]
# [0 .. $num_submember_entries{ $cat . " " . $i } ]
# [0] -> name
# [1] -> options
#
# $demo_options{$dir_and_launch}[0] -> date of options
# $demo_options{$dir_and_launch}[1] -> number of options
# $demo_options{$dir_and_launch}[2 .. ][0] -> options - cat
# $demo_options{$dir_and_launch}[2 .. ][1] -> options - name
#
# $portalis_options{$launch}[ 0 .. $num_portalis_options{$launch} ][0] -> cat
# $portalis_options{$launch}[ 0 .. $num_portalis_options{$launch} ][1] -> mem
#
# $portalis_needs{$launch}[ 0 .. $num_portalis_options{$launch} ][0] -> cat
# $portalis_needs{$launch}[ 0 .. $num_portalis_options{$launch} ][1] -> mem
#
###
#################################
# returns "no"
# returns "maybe"
# returns "yes"
sub legal_config {
my $cat, $mem;
($cat, $mem) = @_;
if ($cat eq "movement") {
if ($mem eq "mouse") {
return "yes";
}
elsif ($mem eq "flybox") {
return "maybe";
} # mouse and flybox
} # -movement
elsif ($cat eq "pipes") {
if ($mem eq "single") {
if ($_num_pipes >= 1) {
return "yes";
}
else {
return "no";
}
} # single
elsif ($mem eq "triple") {
if ($_num_pipes >= 3) {
return "yes";
}
else {
return "no";
}
} # triple
elsif (($mem eq "seos") ||
($mem eq "panoram")) {
if ($_num_pipes >= 3) {
return "maybe";
}
else {
return "no";
}
} # seos and panoram
} # -pipes
elsif ($cat eq "sound") {
if ($mem eq "none") {
return "yes";
} # none
elsif ($mem eq "built_in") {
if ($_have_sound_built_in) {
return "yes";
}
else {
return "no";
}
} # built_in
elsif ($mem eq "emu3") {
return "maybe";
} # emu3
} # -sound
# For things added into optionconfig.info with no detection code...
return "maybe";
} # legal_config
# read option config file - all possible things a demo and/or machine can list
sub read_option_config {
unless (open(optionF,"<$option_config")) {
die_exit "Can't open file $option_config for read\n";
}
while ($line = <optionF>) {
chop $line;
if ((substr($line, 0, 1) eq "#") || # comment
(length($line) == 0)) { # blank line
next;
}
if ($line =~ /^need:/) {
($cat, $mem, $name) = $line =~ /^need:\s*(\S+)\s+(\S+)\s+"(.*)"/;
if ($cat eq "") {
die_exit "Can't parse need [$line] in $option_config\n";
}
if ($num_need_entries{$cat} eq "") {
$num_need_entries{$cat} = 1;
$need_cat_entries[$#need_cat_entries+1] = $cat;
}
else {
$num_need_entries{$cat}++;
}
# sanity check of option config file
for ($i = 0; $i < $num_need_entries{$cat}-1; $i++) {
if ($mem eq $need_entries{$cat}[$i][0]) {
die_exit "Multiple need entries of $cat $mem in ",
"$option_config\n";
}
}
$need_entries{$cat}[($num_need_entries{$cat}-1)][0] = $mem;
$need_entries{$cat}[($num_need_entries{$cat}-1)][1] = $name;
} # need
elsif ($line =~ /^option:/) {
($cat, $mem, $name, $config_option, $config_example, $config_vars) =
$line =~ /^option:\s*(\S+)\s+(\S+)\s+"(.*)"\s+"(.*)"\s+(\S+)\s+(\S+)/;
if ($cat eq "") {
($cat, $mem, $name) = $line =~ /^option:\s*(\S+)\s+(\S+)\s+"(.*)"/;
}
if ($cat eq "") {
die_exit "Can't parse option [$line] in $option_config\n";
}
if ($num_option_entries{$cat} eq "") {
$num_option_entries{$cat} = 1;
$option_cat_entries[$#option_cat_entries+1] = $cat;
}
else {
$num_option_entries{$cat}++;
}
# sanity check of option config file
for ($i = 0; $i < $num_option_entries{$cat}-1; $i++) {
if ($mem eq $option_entries{$cat}[$i][0]) {
die_exit "Multiple option entries of $cat $mem in ",
"$option_config\n";
}
}
$option_entries{$cat}[($num_option_entries{$cat}-1)][0] = $mem;
$option_entries{$cat}[($num_option_entries{$cat}-1)][1] = $name;
$option_entries{$cat}[($num_option_entries{$cat}-1)][2] =
$config_option;
$option_entries{$cat}[($num_option_entries{$cat}-1)][3] =
$config_example;
$option_entries{$cat}[($num_option_entries{$cat}-1)][4] = $config_vars;
} # option
else {
die_exit "Unknown tag - can't parse [$line] in $option_config\n";
}
} # while
close(optionF);
} # read_option_config
# read lines from system config - things this machine has (configured)
sub read_system_config {
($in_reconfig) = @_;
unless (open(configF,"<$system_config")) {
print STDERR "Can't open file $system_config for read.\n";
print STDERR "\tAssuming empty...\n";
return;
}
while ($line = <configF>) {
chop $line;
if ((substr($line, 0, 1) eq "#") || # comment
(length($line) == 0)) { # blank line
next;
}
($cat, $mem, $name, $config_options) =
$line =~ /^\s*(\S+)\s+(\S+)\s+"(.*)"\s+(\S+)/;
if ($cat eq "") {
($cat, $mem, $name) = $line =~ /^\s*(\S+)\s+(\S+)\s+"(.*)"/;
}
if ($cat eq "") {
die_exit "Can't parse [$line] in $system_config\n";
}
$found = 0;
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
if ($option_entries{$cat}[$i][0] eq $mem) {
$found++;
@opts = split(/,/, $config_options);
@opts_needed = split(/,/, $option_entries{$cat}[$i][2]);
if ($#opts != $#opts_needed) {
die_exit "Not correct number of options [$config_options] " .
"for $cat $name in $system_config - " .
"<$option_entries{$cat}[$i][2] " .
"- $option_entries{$cat}[$i][3]>\n";
}
$found1 = 0;
for ($k = 0; $k < $num_option_entries{$cat}; $k++) {
$mem1 = $option_entries{$cat}[$k][0];
if ($mem eq $mem1) {
for ($j = 0; $j < $num_submember_entries{$cat . " " . $k};
$j++) {
$name1 = $config_entries{$cat}[$k][$j][0];
if ($name eq $name1) {
$found1++;
}
}
}
}
if ($found1 >= 1) {
print STDERR "Multiple entries of $cat $mem \"$name\" " .
"in:\n\t$system_config - ignoring\n";
}
else {
if (legal_config($cat, $mem) eq "no") {
if ($in_reconfig) {
print STDERR "RECONFIG info - this system " .
"does not support -$cat $mem listed in:\n" .
"\t$system_config\n";
}
else {
print STDERR "Reconfiguring...\n";
# empty out the system entries already read
%config_entries = {};
%num_submember_entries = {};
configure_system();
read_system_config(1);
return;
}
}
else
{
$config_entries{$cat}[$i][$num_submember_entries{
$cat . " " . $i}][0] = $name;
$config_entries{$cat}[$i][$num_submember_entries{
$cat . " " . $i}][1] = $config_options;
$num_submember_entries{$cat . " " . $i}++;
}
}
}
}
if ($found == 0) {
die_exit "$cat $mem not found in $option_config\n";
}
elsif ($found > 1) {
die_exit "$cat $mem found $found times in $option_config\n";
}
} # while
close(configF);
return;
} # read_system_config
# demo config - default ways to run demos on this machine
sub read_demo_config {
unless (open(demoF,"<$demo_config")) {
print STDERR "Can't open file $demo_config for read.\n";
print STDERR "\tAssuming empty...\n";
return;
}
while ($line = <demoF>) {
chop $line;
if ((substr($line, 0, 1) eq "#") || # comment
(length($line) == 0)) { # blank line
next;
}
($date, $run) = $line =~ /^(\d+)\s+(\S+)/;
if (!$run) {
die_exit("Can't parse [$line] in $demo_config\n");
}
if ($demo_options{$run}) {
die_exit("Multiple entries of $run in $demo_config\n");
}
$demo_options{$run}[0] = $date;
$demo_options{$run}[1] = 0;
$old_pos = -1;
while (($pos = index($line, "-", $old_pos + 1)) > 0) {
$subline = substr($line, $pos);
$old_pos = $pos;
if (($tmp_pos = index($subline, "-", 1)) > 0) {
$tmpline = substr($subline, 0, $tmp_pos);
}
else {
$tmpline = $subline;
}
($cat, $name) = $tmpline =~ /^-(\S+)\s+"(.+)"/;
$found = 0;
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
$mem1 = $option_entries{$cat}[$i][0];
for ($j = 0; $j < $num_submember_entries{$cat . " " . $i}; $j++) {
$name1 = $config_entries{$cat}[$i][$j][0];
if ($name eq $name1) {
$found++;
}
}
}
if (!$cat) {
die_exit("Can't totally parse [$line] in $demo_config\n");
}
if ($found != 1) {
$demo_options{$run}[0] = 0;
}
else {
$demo_options{$run}[2+$demo_options{$run}[1]][0] = $cat;
$demo_options{$run}[2+$demo_options{$run}[1]][1] = $name;
$demo_options{$run}[1]++;
}
}
} # while demoF
close(demoF);
} # read_demo_config
sub read_portalis_config {
# .portalis file
unless (open(portalisF,"<$portalis_config")) {
die_exit "Can't open file $portalis_config for read\n";
}
while ($line = <portalisF>) {
chop $line;
if ((substr($line, 0, 1) eq "#") || # comment
(length($line) == 0)) { # blank line
next;
}
($tag) = $line =~ /^(\S+):/;
if ($tag eq "name") {
$launch = "";
}
elsif (($tag eq "name") ||
($tag eq "abort") ||
($tag eq "category") ||
($tag eq "icon") ||
($tag eq "documentation") ||
($tag eq "cicon") ||
($tag eq "dometex") ||
($tag eq "structex") ||
($tag eq "portaltex") ||
($tag eq "portalbacktex") ||
($tag eq "platformtex") ||
($tag eq "platformbordertex") ||
($tag eq "wwaytex")) {
# ignore line
#print STDERR "xxx ";
}
elsif (($tag eq "option") ||
($tag eq "need")) {
($tag, $cat, $mem) = $line =~ /(\S+):\s*(\S+)\s*(\S+)/;
# check entries against option config file
if ($tag eq "option") {
$found = 0;
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
# print STDERR ".. option $mem eq $option_entries{$cat}[$i][0]\n";
if ($mem eq $option_entries{$cat}[$i][0]) {
$found++
}
}
if ($found == 0) {
die_exit "option $cat $mem [from $portalis_config] not found in $option_config\n";
}
$portalis_options{$launch}[$num_portalis_options{$launch}][0] =
$cat;
$portalis_options{$launch}[$num_portalis_options{$launch}][1] =
$mem;
$num_portalis_options{$launch}++;
} # option
elsif ($tag eq "need") {
$found = 0;
for ($i = 0; $i < $num_need_entries{$cat}; $i++) {
# print STDERR ".. need $mem eq $need_entries{$cat}[$i][0]\n";
if ($mem eq $need_entries{$cat}[$i][0]) {
$found++
}
}
if ($found == 0) {
die_exit "need $cat $mem [from $portalis_config] not found in $option_config\n";
}
$portalis_needs{$launch}[$num_portalis_needs{$launch}][0] = $cat;
$portalis_needs{$launch}[$num_portalis_needs{$launch}][1] = $mem;
$num_portalis_needs{$launch}++;
} # need
}
elsif ($tag eq "launch") {
($launch) = $line =~ /launch:\s*(\S+)/;
$num_portalis_options{$launch} = 0;
}
elsif ($tag eq "waitlaunch") {
($launch) = $line =~ /waitlaunch:\s*(\S+)/;
$num_portalis_options{$launch} = 0;
}
else {
die_exit "Don't recognize $portalis_config option $tag\n";
}
} # while portalisF
close(portalisF);
} # read_portalis_config
# print out verbose debugging information
sub print_debug_info {
for ($n = 0; $n < $#option_cat_entries+1; $n++ ) {
$cat = $option_cat_entries[$n];
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
print STDERR "o> [$cat] [$option_entries{$cat}[$i][0]] " .
"[$option_entries{$cat}[$i][1]]";
if ($option_entries{$cat}[$i][2]) {
print STDERR " [$option_entries{$cat}[$i][2]] " .
"[$option_entries{$cat}[$i][3]] " .
"[$option_entries{$cat}[$i][4]]";
}
print STDERR "\n";
}
}
for ($n = 0; $n < $#option_cat_entries+1; $n++ ) {
$cat = $need_cat_entries[$n];
for ($i = 0; $i < $num_need_entries{$cat}; $i++) {
print STDERR "n> [$cat] [$need_entries{$cat}[$i][0]] " .
"[$need_entries{$cat}[$i][1]]\n";
}
}
for ($n = 0; $n < $#option_cat_entries+1; $n++ ) {
$cat = $option_cat_entries[$n];
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
$mem = $option_entries{$cat}[$i][0];
for ($j = 0; $j < $num_submember_entries{$cat . " " . $i}; $j++) {
print STDERR "-> [$cat] [$mem] $j - " .
"[$config_entries{$cat}[$i][$j][0]]";
if ($config_entries{$cat}[$i][$j][1]) {
print STDERR " [$config_entries{$cat}[$i][$j][1]]";
}
print STDERR "\n";
}
}
}
while (($run, $options) = each %demo_options) {
print STDERR "d> $demo_options{$run}[0] $run";
for ($i = 0; $i < $demo_options{$run}[1]; $i++) {
$cat = $demo_options{$run}[$i + 2][0];
$name = $demo_options{$run}[$i + 2][1];
print STDERR " -$cat \"$name\"";
}
print STDERR "\n";
}
for ($i = 0; $i < $num_portalis_options{$_launch}; $i++) {
print STDERR "o? $_launch - [$portalis_options{$_launch}[$i][0]] " .
"[$portalis_options{$_launch}[$i][1]]\n";
}
for ($i = 0; $i < $num_portalis_needs{$_launch}; $i++) {
print STDERR "n? $_launch - [$portalis_needs{$_launch}[$i][0]] " .
"[$portalis_needs{$_launch}[$i][1]]\n";
}
} # print_debug_info
# get hardware inventory/configuration info
sub get_hardware_inventory {
$_num_cpus = `hinv -c processor | fgrep Processors | awk '{print \$1}`;
chop $_num_cpus;
if ($_num_cpus < 1) {
# different hinv format
$_num_cpus = `hinv -c processor | grep ^Processor | wc -l`;
chop $_num_cpus;
}
$_resolution =
`/usr/gfx/gfxinfo | fgrep Managed | head -1 | awk '{print \$3}'`;
chop $_resolution;
($_resolution_x, $_resolution_y) = $_resolution =~ /(\d+)x(\d+)/;
$_cpu_type = `hinv -c processor | fgrep "CPU:" | awk '{print \$3}'`;
chop $_cpu_type;
$_os_ver = `uname -r`;
chop $_os_ver;
$_ = `hinv -c graphics | wc -l`;
($_num_pipes) = /(\d+)/;
$_ = `hinv -c graphics | head -1`;
($_graphics_type) = /:\W+(\w+)/;
if ((($_graphics_type eq "Reality") ||
($_graphics_type eq "InfiniteReality") ||
($_graphics_type eq "InfiniteReality2") ||
($_graphics_type eq "InfiniteReality2E")) &&
(($_resolution_x <= 1280) && ($_resolution_y <= 1024))) {
$_can_dvr = 1;
}
else {
$_can_dvr = 0;
}
if (`hinv -s -c audio`) {
$_have_sound_built_in = 0;
}
else {
$_have_sound_built_in = 1;
}
$_ = `hinv -c memory | fgrep \"Main memory\"`;
($_mb_memory) = /(\d+)/;
$_num_rms = `/usr/gfx/gfxinfo | fgrep RM | head -1 | awk '{print \$1}'`;
chop $_num_rms;
$_ = `/usr/gfx/gfxinfo | fgrep \"Texture Memory\" | head -1`;
($_mb_texture_memory) = /:\s+(\d+)/;
$_orig_gamma = `$ENV{H_DEMOROOT}/Demo_Interfaces/Portalis/bin/gamma.all`;
chop $_orig_gamma;
} # get_hardware_inventory
sub configure_demo {
my @run_list, $i, $j, $n;
for ($n = 0; $n < $num_portalis_options{$_launch}; $n++) {
my $cat = $portalis_options{$_launch}[$n][0];
my $mem = $portalis_options{$_launch}[$n][1];
my $found = 0;
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
my $mem1 = $option_entries{$cat}[$i][0];
for ($j = 0; $j < $num_submember_entries{$cat . " " . $i}; $j++) {
if ($mem eq $mem1) {
my $name = $config_entries{$cat}[$i][$j][0];
$run_list{$cat}[0] ++;
$run_list{$cat}[ $run_list{$cat}[0] ] = $name;
$found++;
}
}
}
if (!$found) {
$name = "";
for ($j = 0; $j < $num_option_entries{$cat}; $j++) {
if ($mem eq $option_entries{$cat}[$j][0]) {
$name = $option_entries{$cat}[$j][1];
}
}
$run_list{$cat}[0] ++;
$run_list{$cat}[ $run_list{$cat}[0] ] = "/$name";
}
}
my $xselect = "";
my $num_choices = 0;
# my @choices; # can't use my - otherwise it won't return correctly
while (($cat, $name) = each %run_list) {
my $pref = "";
for ($i = 0; $i < $demo_options{$launch_str}[1]; $i++) {
if ($cat eq $demo_options{$launch_str}[2+$i][0]) {
$pref = $demo_options{$launch_str}[2+$i][1];
}
}
$choices[$num_choices][1] = "";
for ($i = 1; $i < ($run_list{$cat}[0] + 1); $i ++) {
$name = $run_list{$cat}[$i];
if ($i == 1) {
$xselect .= " -$cat";
}
if ((($pref) && ($pref eq $name)) ||
((!$pref) && ($i == 1))) {
$xselect .= " +\"$name\"";
}
else {
$xselect .= " \"$name\"";
}
}
$choices[$num_choices][0] = $cat;
$num_choices++;
}
my $ret_val;
if ($xselect) {
$prog = "$demo_root/Demo_Interfaces/Portalis/bin/xselect";
$title = "\"Configure Demo\"";
$ret_val = `$prog -title $title $xselect`;
if ($ret_val eq "") {
die_exit "xselect cancel - aborting demo\n";
}
chop $ret_val;
}
else {
$ret_val = "";
}
my $pos, $old_pos, $subline, $tmpline, $tmp_pos;
$old_pos = -1;
my $num_rets = 0;
while (($pos = index($ret_val, "-", $old_pos + 1)) >= 0) {
$subline = substr($ret_val, $pos);
$old_pos = $pos;
if (($tmp_pos = index($subline, "-", 1)) > 0) {
$tmpline = substr($subline, 0, $tmp_pos);
}
else {
$tmpline = $subline;
}
($cat, $name) = $tmpline =~ /^-(\S+)\s+"(.+)"/;
$rets[$num_rets][0] = $cat;
$rets[$num_rets][1] = $name;
$num_rets++;
} # while
for ($i = 0; $i < $num_choices; $i++) {
for ($j = 0; $j < $num_rets; $j++) {
$cat = $choices[$i][0];
if ($cat eq $rets[$j][0]) {
$found = 0;
for ($k = 1; $k < $run_list{$cat}[0] + 1; $k ++) {
$name = $run_list{$cat}[$k];
if ($name eq $rets[$j][1]) {
$found++;
}
}
if ($found == 1) {
$choices[$i][1] = $rets[$j][1];
}
}
}
if (!$choices[$i][1]) {
die_exit "Can't understand ($choices[$i][0]) results from xselect [$ret_val]\n";
}
}
return ($num_choices, $choices);
} # configure_demo
sub configure_system() {
$ret_val = `$demo_root/Demo_Interfaces/Portalis/bin/CHECK xxx -RECONFIG`;
chop($ret_val);
# print STDERR "configure_system - ret_val = [$ret_val]\n";
if ($ret_val ne ";;;exit") {
die_exit("RECONFIG cancel - aborting demo\n");
}
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks) = stat $system_config;
$config_date = $mtime;
} # configure_system
sub reconfigure_system() {
read_system_config(1); # includes checking against hardware inventory
my $xcheckbox = "";
for ($n = 0; $n < $#option_cat_entries+1; $n++ ) {
$cat = $option_cat_entries[$n];
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
$mem = $option_entries{$cat}[$i][0];
$legal = legal_config($cat, $mem);
$printed = "";
$options = $option_entries{$cat}[$i][2];
for ($j = 0; $j < $num_submember_entries{$cat . " " . $i};
$j++) {
if ($legal eq "maybe") {
$xcheckbox .= "/";
}
elsif ($legal eq "yes") {
$xcheckbox .= "+";
}
else {
die_exit "Don't know what to pass xcheckbox - " .
"$legal $options\n";
}
$printed = 1;
$xcheckbox .= "$cat $mem " .
"\"$config_entries{$cat}[$i][$j][0]\"";
if ($config_entries{$cat}[$i][$j][1]) {
$xcheckbox .= " \"$option_entries{$cat}[$i][2]\" ";
if (substr($config_entries{$cat}[$i][$j][1], 0, 1)
eq "/") {
$xcheckbox .= "\\\\";
}
$xcheckbox .= "$config_entries{$cat}[$i][$j][1]";
}
$xcheckbox .= " ";
}
if ((!$printed) || ($options)) {
if ($legal eq "no") {
$xcheckbox .= "-";
}
elsif ($legal eq "maybe") {
$xcheckbox .= ".";
}
elsif (($legal eq "yes") && ($printed)) {
$xcheckbox .= ".";
}
elsif ($legal eq "yes") {
$xcheckbox .= "+";
if ($option_entries{$cat}[$i][2]) {
$xcheckbox .= "$cat $mem " .
"\"$option_entries{$cat}[$i][1]\"";
$xcheckbox .= " \"$option_entries{$cat}[$i][2]\" ";
if (substr($option_entries{$cat}[$i][3], 0, 1)
eq "/") {
$xcheckbox .= "\\\\";
}
$xcheckbox .= "$option_entries{$cat}[$i][3]";
$xcheckbox .= " ";
$xcheckbox .= ".";
}
}
else {
die_exit "Don't know what to pass xcheckbox - " .
"$legal $options\n";
}
$xcheckbox .= "$cat $mem " .
"\"$option_entries{$cat}[$i][1]\"";
if ($option_entries{$cat}[$i][2]) {
$xcheckbox .= " \"$option_entries{$cat}[$i][2]\" ";
if (substr($option_entries{$cat}[$i][3], 0, 1) eq "/") {
$xcheckbox .= "\\\\";
}
$xcheckbox .= "$option_entries{$cat}[$i][3]";
}
$xcheckbox .= " ";
}
}
}
my $ret_val;
if ($xcheckbox) {
$prog = "$demo_root/Demo_Interfaces/Portalis/bin/xcheckbox";
$title = "\"Configure System\"";
print STDERR "$prog -title $title $xcheckbox\n";
$ret_val = `$prog -title $title $xcheckbox`;
if ($ret_val eq "") {
print STDERR "xcheckbox cancel - aborting demo\n";
print ";exit\n";
exit;
}
chop $ret_val;
}
else {
$ret_val = "";
}
unless (open(configF,">$system_config")) {
die_exit "Can't open file $system_config for write\n";
}
print STDERR "Writing to $system_config.\n";
print configF <<_EOM_;
# AUTOMATICALLY GENERATED FILE - EDIT WITH CARE
#
# category member "name" options
# first listed in a category is default
#
_EOM_
# print STDERR "\n";
# print STDERR "$ret_val\n";
$old_pos = -1;
my $num_rets = 0;
while (($pos = index($ret_val, "-", $old_pos + 1)) >= 0) {
$subline = substr($ret_val, $pos);
$old_pos = $pos;
if (($tmp_pos = index($subline, "-", 1)) > 0) {
$tmpline = substr($subline, 0, $tmp_pos);
}
else {
$tmpline = $subline;
}
($cat, $mem, $name, $options) = $tmpline =~
/^-(\S+)\s+(\S+)\s+"(.+)"\s+(\S+)/;
if (!$options) {
($cat, $mem, $name) = $tmpline =~ /^-(\S+)\s+(\S+)\s+"(.+)"/;
}
# $rets[$num_rets][0] = $cat;
# $rets[$num_rets][1] = $name;
# $num_rets++;
print configF "$cat $mem \"$name\"";
if ($options) {
print configF " $options";
}
print configF "\n";
} # while
close configF;
} # reconfigure_system
sub write_demo_options() {
unless (open(demoF,">$demo_config")) {
die_exit "Can't open file $demo_config for write\n";
}
print STDERR "Writing to $demo_config.\n";
print demoF <<_EOM_;
# AUTOMATICALLY GENERATED FILE - EDIT WITH CARE
#
# date directory/RUN options
#
# date is unix date (seconds)
#
# All directories are relative to H_DEMOROOT (/usr/demos by default)
#
# all options are of the form -category "option name"
#
_EOM_
while (($run, $options) = each %demo_options) {
print demoF "$demo_options{$run}[0] $run";
for ($i = 0; $i < $demo_options{$run}[1]; $i++) {
$cat = $demo_options{$run}[$i + 2][0];
$name = $demo_options{$run}[$i + 2][1];
print demoF " -$cat \"$name\"";
}
print demoF "\n";
}
close(demoF);
} # write_demo_options
################################## main ##################################
# read and parse config files
$pos = -1;
$newpos = 0;
while ($newpos > -1) {
$pos = $newpos;
$newpos = index($ARGV[0], "/", $pos+1);
}
$_launch = substr($ARGV[0], $pos + 1);
$_launch_dir = $ENV{"PWD"};
$demo_root = $ENV{"H_DEMOROOT"};
$misc_dir = "$demo_root/Demo_Interfaces/Portalis/misc";
$pos = index($_launch_dir, $demo_root);
if ($pos != 0) {
print STDERR "Running demo ($_launch_dir) from a directory outside $demo_root - disabling default functions\n";
print STDERR "Try setting the variable H_DEMOROOT (default /usr/demos)\n";
$no_default = 1;
}
$_demo_dir = substr($_launch_dir, $pos + length($demo_root) + 1);
$launch_str = "$_demo_dir/$_launch";
$option_config = "$misc_dir/optionconfig.info";
$system_config = "$misc_dir/systemconfig.info";
$demo_config = "$misc_dir/democonfig.info";
$portalis_config = ".portalis";
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks) = stat $option_config;
$option_date = $mtime;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks) = stat $system_config;
$config_date = $mtime;
# demo entries in file are individually dated
#($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
# $blksize,$blocks) = stat $demo_config;
#$demo_date = $mtime;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks) = stat $portalis_config;
$portalis_date = $mtime;
read_option_config();
get_hardware_inventory(); # need to read inventory before checking
read_portalis_config();
#################################
if (0) {
print_debug_info();
}
# set first group of variables for RUN script (will be overridden by options
# on the command line)
for ($c = 0; $c < $#option_cat_entries+1; $c++ ) {
$cat = $option_cat_entries[$c];
$str = "";
for ($i = 0; $i < $num_portalis_options{$_launch}; $i++) {
if (($portalis_options{$_launch}[$i][0] eq $cat)) {
$mem = $portalis_options{$_launch}[$i][1];
if (!$str) {
$str .= "$portalis_options{$_launch}[$i][1]";
print "set _$cat = $str\n";
}
}
}
}
#################################
# parse command line arguments
$argnum = 1;
while ($argnum < $#ARGV + 1) {
$arg = $ARGV[$argnum];
if (($arg eq "-h") || ($arg eq "-help")) {
print STDERR "Usage:\n";
print STDERR "\t$ARGV[0]\t[-h | -help]\n";
print STDERR "\t$ARGV[0]\t[-default | -new_default | -non_default]\n";
print STDERR "\t$ARGV[0]";
$printed_once = "";
for ($c = 0; $c < $#option_cat_entries+1; $c++ ) {
$cat = $option_cat_entries[$c];
$str = "";
for ($i = 0; $i < $num_portalis_options{$_launch}; $i++) {
if (($portalis_options{$_launch}[$i][0] eq $cat)) {
$mem = $portalis_options{$_launch}[$i][1];
if ($str ne "") {
$str .= " | ";
}
$str .= "$portalis_options{$_launch}[$i][1]";
$found = 0;
for ($n = 0; $n < $num_option_entries{$cat}; $n++) {
if ($option_entries{$cat}[$n][0] eq $mem) {
if ($option_entries{$cat}[$n][2] ne "") {
$str .= " <$option_entries{$cat}[$n][2] " .
"- $option_entries{$cat}[$n][3]>";
}
$found++;
}
}
}
}
if ($str ne "") {
if ($printed_once) {
print STDERR "\t";
}
else {
$printed_once = 1;
}
print STDERR "\t[-$cat $str]\n";
}
}
if (!$printed_once) {
print STDERR "\n";
}
goto_exit();
} # help
elsif (($arg eq "-default") ||
($arg eq "-new_default") ||
($arg eq "-non_default")) {
if ($#ARGV != 1) {
die_exit("$arg can not be used with other arguments.\n");
}
if ($no_default) {
die_exit("Default functions disabled.\n");
}
$default_stuff = $arg;
} # -default stuff
elsif ($arg eq "-RECONFIG") {
reconfigure_system();
print STDERR "RECONFIG done...\n";
print ";;;exit\n";
exit;
} # -RECONFIG
else {
$argnum ++;
if ($argnum > $#ARGV) {
die_exit "Not enough arguments for $arg\n";
}
$arg_param = $ARGV[$argnum];
$found = 0;
for ($n = 0; $n < $num_portalis_options{$_launch}; $n++) {
$cat = $portalis_options{$_launch}[$n][0];
$mem = $portalis_options{$_launch}[$n][1];
if (($arg eq "-$cat") && ($arg_param eq $mem)) {
$found++;
last;
}
}
if (!$found) {
die_exit "Didn't understand $arg $arg_param\n";
}
$found = 0;
for ($n = 0; $n < $num_option_entries{$cat}; $n++) {
if ($option_entries{$cat}[$n][0] eq $mem) {
$found++;
last;
}
}
if (!$found) {
die_exit "\t!!Couldn't find $cat $mem in options - " .
"should have already been trapped\n";
}
if ($option_entries{$cat}[$n][2]) {
$argnum ++;
if ($argnum > $#ARGV) {
die_exit "Not correct number of arguments for " .
"$arg $arg_param\n";
}
$arg_opts = $ARGV[$argnum];
@opts = split(/,/, $arg_opts);
@opts_needed = split(/,/, $option_entries{$cat}[$n][4]);
if (0) {
print STDERR "option_entries{$cat}[$n][4] = $option_entries{$cat}[$n][2]\n";
print STDERR "\$#opts = $#opts, \$#opts_needed = $#opts_needed\n";
for ($i = 0; $i < $#opts+1; $i++) {
print STDERR "opts[$i] = $opts[$i], opts_needed = $opts_needed[$i]\n";
}
}
if ($#opts != $#opts_needed) {
die_exit "Not correct number of options [$arg_opts] " .
"for $arg $arg_param " .
"<$option_entries{$cat}[$n][2] " .
"- $option_entries{$cat}[$n][3]>\n";
}
if (legal_config($cat, $mem) eq "no") {
die_exit("This system does not support -$cat $mem " .
"listed on command line.\n");
}
$args_given{$cat} = $mem;
print "set _$cat = $mem\n";
for ($i = 0; $i < $#opts+1; $i++) {
print "set $opts_needed[$i] = $opts[$i]\n";
}
}
else {
print "set _$cat = $mem\n";
}
}
$argnum++;
} # while
#################################
# do default stuff
if ($default_stuff) {
if ($option_date >= $config_date) {
configure_system();
}
# includes checking against hardware inventory
read_system_config(0);
# check for new hardware (things not listed in system config)
$new_stuff = 0;
if ($_num_pipes >= 3) {
$found = 0;
$cat = "pipes";
$mem = "triple";
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
if (($option_entries{$cat}[$i][0] eq $mem) &&
($num_submember_entries{$cat . " " . $i} > 0)) {
$found = 1;
}
}
if (!$found) {
print STDERR "Detected unconfigured $mem $cat - " .
"reconfiguring...\n";
$new_stuff = 1;
}
}
if ($_have_sound_built_in) {
$found = 0;
$cat = "sound";
$mem = "built_in";
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
if (($option_entries{$cat}[$i][0] eq $mem) &&
($num_submember_entries{$cat . " " . $i} > 0)) {
$found = 1;
}
}
if (!$found) {
print STDERR "Detected unconfigured $mem $cat - " .
"reconfiguring...\n";
$new_stuff = 1;
}
}
if ($new_stuff) {
# empty out the system entries already read
%config_entries = {};
%num_submember_entries = {};
configure_system();
read_system_config(0);
}
read_demo_config();
# if -newdefault - always do configuration
# if -defualt and either the systemconfig or .portalis file are newer than
# the date in democonfig (0 is the default date if no entry)
# if -non_default - always do configuration but *do not* save
if (($arg eq "-new_default") ||
($arg eq "-default") &&
(($config_date >= $demo_options{$launch_str}[0]) ||
($portalis_date >= $demo_options{$launch_str}[0])) ||
($arg eq "-non_default")) {
($num_choices, $choices) = configure_demo();
$date = time();
print STDERR "config_date = $config_date, " .
"portalis_date = $portalis_date, date = $date\n";
$demo_options{$launch_str}[0] = $date;
$demo_options{$launch_str}[1] = $num_choices;
for ($i = 0; $i < $num_choices; $i++) {
$demo_options{$launch_str}[2+$i][0] = $choices[$i][0];
$demo_options{$launch_str}[2+$i][1] = $choices[$i][1];
}
if ($arg ne "-non_default") {
write_demo_options();
}
} # -new_default
# run with arguments in $demo_options..
for ($n = 0; $n < $demo_options{$launch_str}[1]; $n++) {
$cat = $demo_options{$launch_str}[2+$n][0];
$name = $demo_options{$launch_str}[2+$n][1];
for ($i = 0; $i < $num_option_entries{$cat}; $i++) {
$mem = $option_entries{$cat}[$i][0];
for ($j = 0; $j < $num_submember_entries{$cat . " " . $i}; $j++) {
$name1 = $config_entries{$cat}[$i][$j][0];
if ($name eq $name1) {
$args_given{$cat} = $mem;
print "set _$cat = $mem\n";
$arg_opts = $config_entries{$cat}[$i][$j][1];
@opts = split(/,/, $arg_opts);
@opts_needed = split(/,/, $option_entries{$cat}[$i][4]);
for ($k = 0; $k < $#opts+1; $k++) {
print "set $opts_needed[$k] = $opts[$k]\n";
}
}
}
}
}
} # default_stuff
#################################
# Check that any necessary arguments were given
for ($c = 0; $c < $#option_cat_entries+1; $c++ ) {
$cat = $option_cat_entries[$c];
$str = "";
for ($i = 0; $i < $num_portalis_options{$_launch}; $i++) {
if (($portalis_options{$_launch}[$i][0] eq $cat)) {
$mem = $portalis_options{$_launch}[$i][1];
if (!$str) {
for ($n = 0; $n < $num_option_entries{$cat}; $n++) {
if ($option_entries{$cat}[$n][0] eq $mem) {
if ($option_entries{$cat}[$n][2] ne "") {
if (!$args_given{$cat}) {
die_exit
"This demo requires a -$cat option...\n";
}
}
}
}
$str .= "$portalis_options{$_launch}[$i][1]";
}
}
}
}
# Check needs
for ($i = 0; $i < $num_portalis_needs{$_launch}; $i++) {
$cat = $portalis_needs{$_launch}[$i][0];
$mem = $portalis_needs{$_launch}[$i][1];
$found = 0;
for ($n = 0; $n < $num_need_entries{$cat}; $n++) {
if ($mem eq $need_entries{$cat}[$n][0]) {
$need_str = $need_entries{$cat}[$n][1];
$found++;
}
}
if ($found == 0) {
die_exit "\t!! need $cat $mem not found in $option_config - " .
"should have already been trapped\n";
}
# print STDERR "Checking need $cat $mem - [$need_str].\n";
if ($cat eq "mb_memory") {
if ($mem > $_mb_memory) {
die_exit "Need $need_str, only have $_mb_memory.\n";
}
}
elsif ($cat eq "graphics") {
if (
(($mem eq "RealityEngineII") &&
(($_graphics_type ne "RealityEngineII") &&
($_graphics_type ne "Reality") &&
($_graphics_type ne "InfiniteReality") &&
($_graphics_type ne "InfiniteReality2") &&
($_graphics_type ne "InfiniteReality2E"))) ||
(($mem eq "Reality") &&
(($_graphics_type ne "Reality") &&
($_graphics_type ne "InfiniteReality") &&
($_graphics_type ne "InfiniteReality2") &&
($_graphics_type ne "InfiniteReality2E"))) ||
(($mem eq "InfiniteReality") &&
(($_graphics_type ne "InfiniteReality") &&
($_graphics_type ne "InfiniteReality2") &&
($_graphics_type ne "InfiniteReality2E"))) ||
(($mem eq "InfiniteReality2") &&
($_graphics_type ne "InfiniteReality2") &&
($_graphics_type ne "InfiniteReality2")) ||
(($mem eq "InfiniteReality2E") &&
($_graphics_type ne "InfiniteReality2E"))
) {
die_exit "Need $need_str, only have $_graphics_type.\n";
}
}
elsif ($cat eq "mb_texture_memory") {
if ($mem > $_mb_texture_memory) {
die_exit "Need $need_str, only have $_mb_texture_memory.\n";
}
}
elsif ($cat eq "num_rms") {
if ($mem > $_num_rms) {
die_exit "Need $need_str, only have $_num_rms.\n";
}
}
elsif ($cat eq "num_cpus") {
if ($mem > $_num_cpus) {
die_exit "Need $need_str, only have $_num_cpus.\n";
}
}
elsif ($cat eq "processor") {
if (
(($mem eq "R4400") &&
(($_cpu_type ne "R4400") &&
($_cpu_type ne "R5000") &&
($_cpu_type ne "R10000"))) ||
(($mem eq "R5000") &&
(($_cpu_type ne "R5000") &&
($_cpu_type ne "R10000"))) ||
(($mem eq "R10000") &&
($_cpu_type ne "R10000"))
) {
die_exit "Need $need_str, only have $_cpu_type.\n";
}
}
else {
die_exit "\t!! Missing need $cat ($mem)\n" .
"\tneed to add support in CHECK or remove from\n" .
"\t$option_config\n";
} # graphics
} # num_portalis_needs
#################################
# set variables for RUN script
print "set _launch = $_launch\n";
print "set _launch_dir = $_launch_dir\n";
print "set _cpu_type = $_cpu_type\n";
print "set _graphics_type = $_graphics_type\n";
print "set _can_dvr = $_can_dvr\n";
print "set _have_sound_built_in = $_have_sound_built_in\n";
print "set _mb_memory = $_mb_memory\n";
print "set _mb_texture_memory = $_mb_texture_memory\n";
print "set _num_cpus = $_num_cpus\n";
print "set _num_pipes = $_num_pipes\n";
print "set _num_rms = $_num_rms\n";
print "set _orig_gamma = $_orig_gamma\n";
print "set _os_ver = $_os_ver\n";
print "set _resolution = $_resolution\n";
print "set _resolution_x = $_resolution_x\n";
print "set _resolution_y = $_resolution_y\n";
Here's the optionconfig.info file:
Code: #
# Portalis supports demos with have configurable options...
#
# The names, formats, etc. of these entries is tied the the CHECK program - any
# changes in this file or the CHECK program *need* to be propogated to the
# other!
#
# The format is as follows:
# option: category member "name" ["option string" example variables]
# need: category member "name"
#
# category - This specifies the category of this option. All the items in a
# category are presented as a bunch of radio buttons (ie. only one is
# chosen). The first is always the default - make sure the default is the
# least common denominator (and in the case of options, preferably does not
# have configurable options).
# member - This is the a member of the category...
# "name" - This should be enclosed in quotes (to allow spaces). This is human
# readable text of the name (vs. the machine readable member).
# "option string" - This should also be enclosed in quotes.
# This is optional, so should only be used when there is an parameter to
# specify. But when it is used an example and a list of variables are
# required as well.
# example - The example can not have any spaces - so if multiple options are
# needed they must be seperated by a comma only.
# variables - This is a comma seperated list (no spaces) of the variables that
# will be set for the RUN script to use...
#
# For example: if $_pipes is set to seos then the variables $_pipeL, etc.
# will contain the values passed to the run script.
option: movement mouse "Mouse"
option: movement flybox "Flybox" "port" /dev/ttyd2 _flybox_port
option: pipes single "Single Pipe"
option: pipes triple "Three Pipe" "Order (L,M,R)" 0,1,2 _pipeL,_pipeM,_pipeR
option: pipes seos "SEOS" "Order (L,M,R), HFOV, VFOV, Hoffset" 0,1,2,57,46,53.33 _pipeL,_pipeM,_pipeR,_pipeHFOV,_pipeVFOV,_pipeOffset
option: pipes panoram "Panoram" "Order (L,M,R)" 0,1,2 _pipeL,_pipeM,_pipeR
option: sound none "No sound"
option: sound built_in "Built in sound"
option: sound emu3 "EMU IIIxp"
need: mb_memory 256 " 256 M system memory"
need: mb_memory 512 " 512 M system memory"
need: mb_memory 768 " 768 M system memory"
need: mb_memory 1024 "1024 M system memory"
need: mb_memory 1280 "1280 M system memory"
need: mb_memory 1536 "1536 M system memory"
need: mb_memory 1792 "1792 M system memory"
need: mb_memory 2048 "2048 M system memory"
need: mb_memory 2560 "2560 M system memory"
need: mb_memory 3072 "3072 M system memory"
need: mb_memory 4096 "4096 M system memory"
need: graphics InfiniteReality "Onyx InfiniteReality graphics"
need: graphics InfiniteReality2 "Onyx2 InfiniteReality graphics"
need: graphics Reality "Onyx2 Reality graphics"
need: graphics RealityEngineII "Onyx RealityEngineII graphics"
# 1 is redundant
# need: num_rms 1 "1 Raster Manager graphics board"
need: num_rms 2 "2 Raster Manager graphics boards"
need: num_rms 4 "4 Raster Manager graphics boards"
need: mb_texture_memory 4 " 4 M (graphics) Texture memory"
need: mb_texture_memory 16 " 16 M (graphics) Texture memory"
need: mb_texture_memory 64 " 64 M (graphics) Texture memory"
need: mb_texture_memory 256 "256 M (graphics) Texture memory"
# 1 is redundant
# need: num_cpus 1 " 1 CPU"
need: num_cpus 2 " 2 CPUs"
need: num_cpus 4 " 4 CPUs"
need: num_cpus 8 " 8 CPUs"
need: num_cpus 16 "16 CPUs"
need: num_cpus 32 "32 CPUs"
need: processor R10000 "CPU(s) are R10000 processor(s)"
need: processor R4400 "CPU(s) are R4400 processor(s)"
need: processor R5000 "CPU(s) are R5000 processor(s)"
(This post was last modified: 04-04-2019, 05:54 PM by Irinikus.)
|
|
Irinikus
Hardware Connoisseur
Trade Count:
(0)
Posts: 3,475
Threads: 319
Joined: Dec 2017
Location: South Africa
|