line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Rezrov::ZIO_test;
|
2
|
|
|
|
|
|
|
# z-machine i/o for test model - meant for capturing output as part of a test
|
3
|
|
|
|
|
|
|
# - contributed by Neil Bowers, Aug 2004
|
4
|
|
|
|
|
|
|
# - modified by Michael Edmonson:
|
5
|
|
|
|
|
|
|
# - stripped down even further.
|
6
|
|
|
|
|
|
|
# - avoid using ANY local system calls or external modules (GetKey/GetSize).
|
7
|
|
|
|
|
|
|
# This means single-key input will not work, but also "make test"
|
8
|
|
|
|
|
|
|
# might stop crashing in unusual configurations! :P
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
493
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
507
|
use Games::Rezrov::ZIO_Generic;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
693
|
|
13
|
|
|
|
|
|
|
@Games::Rezrov::ZIO_test::ISA = qw(Games::Rezrov::ZIO_Generic);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $rows = 25;
|
16
|
|
|
|
|
|
|
my $columns = 80;
|
17
|
|
|
|
|
|
|
my $abs_x = 0;
|
18
|
|
|
|
|
|
|
my $abs_y = 0;
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$|=1;
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new {
|
23
|
1
|
|
|
1
|
0
|
42
|
my ($type, %options) = @_;
|
24
|
1
|
|
|
|
|
12
|
my $self = new Games::Rezrov::ZIO_Generic(%options);
|
25
|
1
|
|
|
|
|
4
|
bless $self, $type;
|
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
5
|
$columns = $options{columns} if $options{columns};
|
28
|
1
|
|
|
|
|
37
|
$self->zio_options(\%options);
|
29
|
1
|
|
|
|
|
6
|
($columns, $rows) = get_size();
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
5
|
return $self;
|
32
|
|
|
|
|
|
|
}
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_size {
|
35
|
1
|
|
|
1
|
0
|
4
|
return ($columns, $rows);
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_key {
|
39
|
|
|
|
|
|
|
# single-key input disabled!
|
40
|
0
|
|
|
0
|
0
|
0
|
return "";
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub write_string {
|
44
|
24
|
|
|
24
|
0
|
63
|
my ($self, $string, $x, $y) = @_;
|
45
|
|
|
|
|
|
|
# $self->absolute_move($x, $y) if defined($x) and defined($y);
|
46
|
24
|
|
|
|
|
842
|
print $string;
|
47
|
24
|
|
|
|
|
100
|
$abs_x += length($string);
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
0
|
0
|
sub clear_to_eol {
|
51
|
|
|
|
|
|
|
# do nothing
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
0
|
0
|
sub update {
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub can_split {
|
58
|
|
|
|
|
|
|
# true or false: can this zio split the screen?
|
59
|
3
|
|
|
3
|
0
|
38
|
return 0;
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub set_version {
|
63
|
1
|
|
|
1
|
0
|
10
|
my ($self, $status_needed, $callback) = @_;
|
64
|
1
|
|
|
|
|
37
|
Games::Rezrov::StoryFile::rows($rows);
|
65
|
1
|
|
|
|
|
6
|
Games::Rezrov::StoryFile::columns($columns);
|
66
|
1
|
|
|
|
|
3
|
return 0;
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub absolute_move {
|
70
|
4
|
|
|
4
|
0
|
18
|
($abs_x, $abs_y) = @_[1,2];
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub newline {
|
74
|
28
|
|
|
28
|
0
|
10543
|
print "\n";
|
75
|
28
|
|
|
|
|
163
|
$abs_x = 0;
|
76
|
|
|
|
|
|
|
# Games::Rezrov::StoryFile::register_newline();
|
77
|
|
|
|
|
|
|
# never register newlines to the interpreter,
|
78
|
|
|
|
|
|
|
# so [MORE] prompt will never appear.
|
79
|
|
|
|
|
|
|
}
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub write_zchar {
|
82
|
0
|
0
|
|
0
|
0
|
0
|
if ($_[0]->current_window() == Games::Rezrov::ZConst::LOWER_WIN) {
|
83
|
0
|
|
|
|
|
0
|
print chr($_[1]);
|
84
|
0
|
|
|
|
|
0
|
$abs_x++;
|
85
|
|
|
|
|
|
|
} else {
|
86
|
|
|
|
|
|
|
# upper window character, ignore
|
87
|
|
|
|
|
|
|
# printf STDERR "ignoring char: %s\n", chr($_[1]);
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_input {
|
92
|
0
|
|
|
0
|
0
|
0
|
my ($self, $max, $single_char, %options) = @_;
|
93
|
0
|
0
|
|
|
|
0
|
if ($single_char) {
|
94
|
0
|
|
|
|
|
0
|
return get_key();
|
95
|
|
|
|
|
|
|
} else {
|
96
|
0
|
|
|
|
|
0
|
my $line;
|
97
|
0
|
0
|
|
|
|
0
|
if ($self->listening) {
|
|
|
0
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# speech recognition; disable for this interface?
|
99
|
0
|
|
|
|
|
0
|
$line = $self->recognize_line();
|
100
|
0
|
|
|
|
|
0
|
print "$line\n";
|
101
|
|
|
|
|
|
|
} elsif ($self->using_term_readline()) {
|
102
|
|
|
|
|
|
|
# Term::ReadLine enabled
|
103
|
0
|
|
|
|
|
0
|
$line = $self->readline($options{"-preloaded"});
|
104
|
|
|
|
|
|
|
} else {
|
105
|
0
|
|
|
|
|
0
|
$line = ;
|
106
|
|
|
|
|
|
|
# also doesn't work with v5+ preloaded input
|
107
|
|
|
|
|
|
|
}
|
108
|
0
|
0
|
|
|
|
0
|
unless (defined $line) {
|
109
|
0
|
|
|
|
|
0
|
$line = "";
|
110
|
0
|
|
|
|
|
0
|
print "\n";
|
111
|
|
|
|
|
|
|
}
|
112
|
0
|
|
|
|
|
0
|
chomp $line;
|
113
|
0
|
|
|
|
|
0
|
return $line;
|
114
|
|
|
|
|
|
|
}
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub get_position {
|
118
|
22
|
|
|
22
|
0
|
48
|
my ($self, $sub) = @_;
|
119
|
22
|
100
|
|
|
|
50
|
if ($sub) {
|
120
|
3
|
|
|
0
|
|
22
|
return sub { };
|
|
0
|
|
|
|
|
0
|
|
121
|
|
|
|
|
|
|
} else {
|
122
|
19
|
|
|
|
|
68
|
return ($abs_x, $abs_y);
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
|
126
|
2
|
|
|
2
|
0
|
36
|
sub clear_screen {
|
127
|
|
|
|
|
|
|
# do nothing
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub set_window {
|
131
|
4
|
|
|
4
|
0
|
11
|
my ($self, $window) = @_;
|
132
|
4
|
|
|
|
|
27
|
$self->SUPER::set_window($window);
|
133
|
|
|
|
|
|
|
}
|
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
0
|
0
|
|
sub erase_chars {
|
136
|
|
|
|
|
|
|
# do nothing
|
137
|
|
|
|
|
|
|
}
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1;
|