1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
/*
** File: print.c
**
** (C)opyright 1987-1992 InfoTaskforce.
*/
#include "infocom.h"
/*
** Print Routine Global Variables
**
** Note:
** The variables "p_buff_ptr" and "p_buff_end" are of
** type "byte *" NOT "byte_ptr" - these definitions are
** different for MSDOS Compilers ("byte_ptr" is huge).
*/
byte p_buff_strt[MAX_LINE_LENGTH] ;
byte *p_buff_ptr ;
byte *p_buff_end ;
Void
init_print ()
{
extern header data_head ;
extern int screen_width ;
extern int linecount ;
extern boolean enable_screen ;
extern boolean disable_script ;
extern proc_ptr PrintChar ;
extern boolean windowing_enabled ;
extern word current_window ;
extern boolean use_buffered_io ;
extern word top_screen_line ;
linecount = 0 ;
enable_screen = TRUE ;
disable_script = FALSE ;
PrintChar = print_char ;
p_buff_ptr = p_buff_strt ;
p_buff_end = &p_buff_strt[screen_width - 1] ;
windowing_enabled = FALSE ;
current_window = 0 ;
use_buffered_io = TRUE ;
if ( data_head.z_code_version <= VERSION_3 )
top_screen_line = STD_TOP_SCREEN_LINE ;
else
top_screen_line = PLUS_TOP_SCREEN_LINE ;
}
Void
flush_prt_buff ()
{
extern int linecount ;
print_buffer ( p_buff_ptr ) ;
p_buff_ptr = p_buff_strt ;
linecount = 0 ;
}
Void
print_num ( number )
word number ;
{
extern proc_ptr PrintChar ;
int num ;
if ( number == 0 )
(*PrintChar)( (word)'0' ) ;
else
{
num = (signed_word)number ;
if ( num < 0 )
{
num = -num ;
(*PrintChar)( (word)'-' ) ;
}
PrintNumber ( num ) ;
}
}
Void
PrintNumber ( num )
int num ;
{
extern proc_ptr PrintChar ;
word ch ;
if ( num > 9 )
PrintNumber ( num / 10 ) ;
ch = '0' + ( num % 10 ) ;
(*PrintChar)( ch ) ;
}
Void
std_print2 ( address )
word address ;
{
word page ;
word offset ;
page = STD_PAGE ( address ) ;
offset = STD_OFFSET ( address ) ;
print_coded ( &page,&offset ) ;
}
Void
plus_print2 ( address )
word address ;
{
word page ;
word offset ;
page = PLUS_PAGE ( address ) ;
offset = PLUS_OFFSET ( address ) ;
print_coded ( &page,&offset ) ;
}
Void
print1 ( address )
word address ;
{
word page ;
word offset ;
page = address / BLOCK_SIZE ;
offset = address % BLOCK_SIZE ;
print_coded ( &page,&offset ) ;
}
Void
std_p_obj ( obj_num )
word obj_num ;
{
extern std_object_ptr std_obj_list ;
std_object_ptr obj ;
word address ;
obj = STD_OBJ_ADDR ( obj_num ) ;
address = ((obj -> prop_ptr[0]) << 8) + (obj -> prop_ptr[1]) + 1 ;
print1 ( address ) ;
}
Void
plus_p_obj ( obj_num )
word obj_num ;
{
extern plus_object_ptr plus_obj_list ;
plus_object_ptr obj ;
word address ;
obj = PLUS_OBJ_ADDR ( obj_num ) ;
address = ((obj -> prop_ptr[0]) << 8) + (obj -> prop_ptr[1]) + 1 ;
print1 ( address ) ;
}
Void
wrt ()
{
extern word pc_page ;
extern word pc_offset ;
print_coded ( &pc_page,&pc_offset ) ;
fix_pc () ;
}
Void
writeln ()
{
wrt () ;
new_line () ;
ret_true () ;
}
Void
new_line ()
{
*p_buff_ptr++ = '\n' ;
print_buffer ( p_buff_ptr ) ;
p_buff_ptr = p_buff_strt ;
}
Void
print_char ( ch )
word ch ;
{
extern boolean use_buffered_io ;
extern boolean use_internal_buffer ;
extern byte_ptr internal_io_ptr ;
extern word int_io_buff_length ;
byte *ptr ;
/*
** Note:
** The variable "ptr" is of type "byte *"
** NOT "byte_ptr" - these definitions are
** different for MSDOS Compilers ("byte_ptr" is huge).
*/
if ( use_internal_buffer == TRUE )
{
*internal_io_ptr++ = (byte)ch ;
++int_io_buff_length ;
return ;
}
if ( use_buffered_io == FALSE )
{
out_char ( (char)ch ) ;
return ;
}
if ( p_buff_ptr == p_buff_end )
{
if ( ch == (word)' ' )
{
print_buffer ( p_buff_end ) ;
out_char ( '\n' ) ;
p_buff_ptr = p_buff_strt ;
return ;
}
else
{
--p_buff_ptr ;
while ((*p_buff_ptr != (byte)' ') && (p_buff_ptr != p_buff_strt))
--p_buff_ptr ;
if ( p_buff_ptr == p_buff_strt )
{
print_buffer ( p_buff_end ) ;
out_char ( '\n' ) ;
}
else
{
print_buffer ( ++p_buff_ptr ) ;
out_char ( '\n' ) ;
ptr = p_buff_strt ;
while ( p_buff_ptr != p_buff_end )
*ptr++ = *p_buff_ptr++ ;
p_buff_ptr = ptr ;
}
}
}
*p_buff_ptr++ = (byte)ch ;
}
Void
print_buffer ( buff_end )
byte *buff_end ;
{
byte *ptr = p_buff_strt ;
/*
** Note:
** The parameter "buff_end" and the variable "ptr"
** are of type "byte *" NOT "byte_ptr" - these
** definitions are different for MSDOS Compilers ("byte_ptr" is huge).
*/
while ( ptr != buff_end )
out_char ( (char)*ptr++ ) ;
}
|