10
screensize = maxx * maxy * bytespercell;
12
linB8000 = $B800 * 16;
15
string80 = string[80];
18
text_save : array[0..screensize-1] of byte;
19
text_oldx, text_oldy : Word;
23
procedure status(s : string80);
25
gotoxy(1, 1); clreol; write(s); readkey;
28
procedure selinfo(sel : Word);
31
clreol; writeln('Descriptor base address : $',
32
hexstr(get_segment_base_address(sel), 8));
33
clreol; write('Descriptor limit : ', get_segment_limit(sel));
36
function makechar(ch : char; color : byte) : Word;
38
result := byte(ch) or (color shl 8);
42
seg_move(dosmemselector, linB8000, get_ds, longint(@text_save),
44
text_oldx := wherex; text_oldy := wherey;
45
seg_fillword(dosmemselector, linB8000, screensize div 2,
46
makechar(' ', Black or (Black shl 4)));
47
status('Creating selector ''text_sel'' to a part of ' +
48
'text screen memory');
49
text_sel := allocate_ldt_descriptors(1);
50
set_segment_base_address(text_sel,
51
linB8000 + bytespercell * maxx * 1);
52
set_segment_limit(text_sel, screensize - 1 - bytespercell *
56
status('and clearing entire memory selected by ''text_sel''' +
58
seg_fillword(text_sel, 0, (get_segment_limit(text_sel)+1) div 2,
59
makechar(' ', LightBlue shl 4));
61
status('Notice that only the memory described by the' +
62
' descriptor changed, nothing else');
64
status('Now reducing it''s limit and base and setting it''s ' +
66
set_segment_base_address(text_sel,
67
get_segment_base_address(text_sel) + bytespercell * maxx);
68
set_segment_limit(text_sel,
69
get_segment_limit(text_sel) - bytespercell * maxx * 2);
71
status('Notice that the base addr increased by one line but ' +
72
'the limit decreased by 2 lines');
73
status('This should give you the hint that the limit is ' +
74
'relative to the base');
75
seg_fillword(text_sel, 0, (get_segment_limit(text_sel)+1) div 2,
76
makechar(#176, LightMagenta or Brown shl 4));
78
status('Now let''s get crazy and copy 10 lines of data from ' +
79
'the previously saved screen');
80
seg_move(get_ds, longint(@text_save), text_sel,
81
maxx * bytespercell * 2, maxx * bytespercell * 10);
83
status('At last freeing the descriptor and restoring the old '+
84
' screen contents..');
85
status('I hope this little program may give you some hints on '+
86
'working with descriptors');
87
free_ldt_descriptor(text_sel);
88
seg_move(get_ds, longint(@text_save), dosmemselector,
89
linB8000, screensize);
90
gotoxy(text_oldx, text_oldy);
b'\\ No newline at end of file'