Language-Zcode
view release on metacpan or search on metacpan
lib/Language/Zcode/Runtime/IO.pm view on Meta::CPAN
my $current_window = Games::Rezrov::ZConst::LOWER_WIN;
# XXX get rid of this
sub current_window { $current_window }
# HACKS, FIX ME [ADK: No kidding]
#my ($upper_lines, $lower_lines);
# Need to use from other packages
use vars qw($upper_lines $lower_lines);
# Call once when starting the program
sub start_IO {
my ($r, $c, $t) = @_;
# TODO intelligently figure out which terminal to use if none was given
$t = "dumb" unless defined $t;
# XXX These two lines mean I don't need to input -r/-c while
# testing with the ZIO_dumb interface.
# warn "For now, I'm ignoring -r and -c options\n" if $r || $c;
if ($t eq "dumb") {$r ||= 24; $c ||= 80}
if ($t eq "dumb") {
$zio = new Games::Rezrov::ZIO_dumb(rows=>$r, columns =>$c);
} elsif ($t eq "win32") {
$zio = new Games::Rezrov::ZIO_Win32(rows=>$r, columns =>$c);
} else {
die "Unknown terminal '$t'\n";
}
$zio->set_window(Games::Rezrov::ZConst::LOWER_WIN);
PlotzPerl::Output::start_output($zio);
# erase_window call in setup_IO calls clear_screen
# $zio->clear_screen();
}
# Call again for restart
sub setup_IO {
# XXX I don't handle undo yet ADK
# $undo_slots = [];
# cursor positions for individual windows
$window_cursors = [];
PlotzPerl::Output::setup();
Language::Zcode::Runtime::Input::setup();
# HACKS, FIX ME
# $zio->set_version($self);
# collapses the upper window
# XXX do we really want to clear screen on a restart?
erase_window(-1);
# Centralized management of the status line.
# Perform a split_window(), we'll use the "upper window"
# for the status line.
# This is BROKEN: Seastalker is a v3 game that uses the upper window!
=pod
# So [ADK] split to a SECOND window. This split will be internal to
# the Z-machine emulator: the Z-machine isn't able to split to more
# than one window (in v5), but presumably any I/O that can split once
# can split more than once. Put status in that window.
#
# Tk already does that. Just use manual_status_line for
# everything.
=cut
if ($main::Constants{version} <= 3 &&
$zio->can_split() &&
!$zio->manual_status_line()) {
split_window(1);
}
# XXX ADK I think we don't need the $current_window line below - that
# is taken care of by set_window
# $current_window = Games::Rezrov::ZConst::LOWER_WIN;
set_window(Games::Rezrov::ZConst::LOWER_WIN);
}
# Read IO stuff from header, write some back depending on interpreter/IO
sub update_header {
my $version = $main::Constants{version};
# First do flags1 stuff
# a "time" game: 8.2.3.2
#my $f1 = PlotzMemory::get_byte_at(FLAGS_1);
my $f1 = $PlotzMemory::Memory[FLAGS_1];
my $start_rows = rows();
my $start_columns = columns();
# $f1 |= TANDY if Games::Rezrov::ZOptions::TANDY_BIT();
# turn on the "tandy bit"
if ($version <= 3) {
if ($zio->can_split()) {
$f1 |= SCREEN_SPLITTING_AVAILABLE;
$f1 &= ~ STATUS_NOT_AVAILABLE;
} else {
$f1 &= ~ SCREEN_SPLITTING_AVAILABLE;
$f1 |= STATUS_NOT_AVAILABLE;
}
# XXX copied from Games::Rezrov::ZHeader. Isn't this backwards?!
if ($zio->fixed_font_default()) {
$f1 |= VARIABLE_FONT_DEFAULT;
} else {
$f1 &= ~VARIABLE_FONT_DEFAULT;
}
# versions 4+
} else {
# Are they always available? Even for dumb term?
$f1 |= BOLDFACE_AVAILABLE;
$f1 |= ITALIC_AVAILABLE;
$f1 |= FIXED_FONT_AVAILABLE;
# $f1 |= 0x80;
$f1 &= ~TIMED_INPUT_AVAILABLE; # timed input NOT available
set_header_columns($start_columns);
set_header_rows($start_rows);
( run in 1.363 second using v1.01-cache-2.11-cpan-71847e10f99 )