home *** CD-ROM | disk | FTP | other *** search
- {-------------------------------------------------------------------------}
- { SC.INC Screen Counter }
- {-------------------------------------------------------------------------}
- { Copyright 1985 }
- { by Lynn A. Canning }
- { 9107 Grandview Dr. }
- { Overland Park, Ks 66212 }
- { This program was placed in the public domain by the author. }
- { It may be used and copied as desired, but it may not be sold. }
- {-------------------------------------------------------------------------}
-
- const
- Menu = 'X = Exit Line Column HTrip VTrip F2 = Trip Reset F1 = Help ';
-
- type
- char_cell = record
- code : char;
- attr : byte;
- end;
-
- screen_type = array[1..25] of array[1..80] of char_cell;
-
- var
- ch : char;
- i,j,l,m,n,o,b,f : byte;
- cx,cy : byte;
- htrip,vtrip : byte;
- saveattr : byte;
- video_mode : byte;
- cursor_color : byte;
- screen : screen_type;
- real_screen : ^screen_type;
- previous : boolean;
- counter_color : byte;
- menu_color : byte;
-
- procedure update_screen(y,lines : byte);
-
- begin
- if video_mode <> 7 then
- repeat until (port[$3da] and 8) = 8; {is raster in vertical retrace}
- if video_mode <> 7 then
- port[$3d8] := 1; {disable video signal}
- move(screen[y],real_screen^[y],lines * 160); {write to screen memory}
- if video_mode <> 7 then
- port[$3d8] := 9; {enable video signal}
- end;
-
- procedure read_screen(y,lines : byte);
-
- begin
- if video_mode <> 7 then
- repeat until (port[$3da] and 8) = 8;
- if video_mode <> 7 then
- port[$3d8] := 1;
- move(real_screen^[y],screen[y],lines * 160); {read screen memory}
- if video_mode <> 7 then
- port[$3d8] := 9;
- end;
-
- procedure move_cursor;
- begin
- if (i = 0) or (i = 25) then begin
- i := l;
- j := m;
- htrip := n;
- vtrip := o;
- write(Chr(7)); {no screen wrap allowed, ring bell}
- end
- else begin
- screen[l,m].attr := saveattr;
- saveattr := screen[i,j].attr;
- screen[i,j].attr := cursor_color;
- update_screen(i,1);
- update_screen(l,1);
- end
- end;
-
- procedure update_menu; {update the menu counters}
- begin
- if video_mode = 7 then
- textbackground(white)
- else
- textbackground(yellow);
- gotoxy(17,25);
- write(i:2);
- gotoxy(28,25);
- write(j:2);
- gotoxy(38,25);
- if htrip = 0 then
- htrip := j;
- write(htrip:2);
- gotoxy(47,25);
- if vtrip = 0 then
- vtrip := i;
- write(vtrip:2);
- end;
-
- procedure CheckInput;
- begin
-
- l := i;
- m := j;
- n := htrip;
- o := vtrip;
-
- Read(Kbd,Ch);
-
- if Ch = chr(27) then begin {check for cursor keys -(ESC x)}
- previous := True;
- Read(Kbd,Ch);
- end
- else previous := False;
-
- if previous and (Ch = '<') then begin {check for F2 key, if found }
- htrip := 1; {reset htrip counter}
- vtrip := 1;
- update_menu;
- end;
-
- if previous and (Ch = ';') then begin {check for F1 key, if found }
- MkWin(1,1,80,25,2,f,b); {pop-up help menu.}
- gotoxy(1,1);
- ClrScr;
- Writeln(' Screen Counter (C) Copyright 1985 by Lynn A. Canning');
- Writeln(' Version 1.00 9107 Grandview');
- Writeln(' Overland Park, Ks 66212');
- Writeln;
- Writeln(' WELCOME TO THE SCREEN COUNTER HELP MENU');
- Writeln;
- Writeln(' CURSOR MOVEMENT KEYS');
- Writeln(' Arrow Keys - move one position in specified direction');
- Writeln(' Home Key - move to beginning of current line');
- Writeln(' End Key - move to end of current line');
- Writeln(' Cntl End - move to beginning of last line');
- Writeln(' Cntl Home - move to beginning of first line');
- Writeln(' Screen Wrap is allowed except at columns 1 and 80');
- Writeln;
- Writeln(' USE OF TRIP COUNTERS');
- Writeln(' Move cursor to the first position to be counted, reset Trip Counters,');
- Writeln(' move cursor to the last position to be counted.');
- Writeln(' F2 - resets Trip Counters');
- Writeln(' X - exits program Screen Counter');
- Writeln(' Note that the Column and Line Counters are the X & Y screen coordinates.');
- Writeln;
- Writeln(' Press Any Key To Continue');
- repeat until keypressed;
- RmWin;
- Textcolor(counter_color);
- end;
-
- if previous and (Ch = 'M') then begin {check for right arrow (ESC M)}
- if j = 80 then begin
- j := 1;
- htrip := 1;
- vtrip := vtrip+1;
- i := i+1;
- end
- else begin
- j := j+1;
- htrip := htrip+1;
- end;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'K') then begin {check for left arrow (ESC K)}
- if j = 1 then begin
- j := 80;
- htrip := j;
- vtrip := vtrip-1;
- i := i-1;
- end
- else begin
- j := j-1;
- htrip := htrip-1;
- end;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'P') then begin {check for down arrow (ESC P)}
- if i = 24 then begin
- i := 1;
- vtrip := i;
- end
- else begin
- i := i+1;
- vtrip := vtrip+1;
- end;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'H') then begin {check for up arrow (ESC H)}
- if i = 1 then begin
- i := 24;
- vtrip := i;
- end
- else begin
- i := i-1;
- vtrip := vtrip-1;
- end;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'G') then begin {check for home key (ESC G)}
- j := 1;
- htrip := 1;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'O') then begin {check for end key (ESC G)}
- j := 80;
- htrip := 80;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'u') then begin {check for cntl end key (ESC G)}
- i := 24;
- j := 1;
- htrip := 1;
- vtrip := i;
- move_cursor;
- update_menu;
- end;
-
- if previous and (Ch = 'w') then begin {check for cntl home key (ESC G)}
- i := 1;
- j := 1;
- htrip := 1;
- vtrip := 1;
- move_cursor;
- update_menu;
- end;
-
- end;
-
- {-------------------------------------------------------------------------}
- { Main Program }
- {-------------------------------------------------------------------------}
- begin
- video_mode := Mem[0000:$0449];
- if video_mode = 7 then begin {7 is monochrome 3 is color graphics 80X25}
- real_screen := ptr($b000,0); {set page offset address for monochrome}
- cursor_color := 240; {black on white}
- counter_color := 0; {black}
- menu_color := 15; {white}
- b := 15; {help menu background - white}
- f := 0; {help menu text - black}
- end
- else begin;
- real_screen := ptr($b800,0); {set page offset address for color graphics}
- cursor_color := 97; {blue on brown}
- counter_color := 1; {blue}
- menu_color := 4; {red}
- b := 0; {help menu background - black}
- f := 6; {help menu test - yellow}
- end;
- fillchar(screen,4000,0);
- cy := wherey;
- cx := wherex;
- I := cy;
- J := cx;
- htrip := J;
- if I = 25 then
- I := 24;
- vtrip := I;
- read_screen(1,25);
- saveattr := screen[i,j].attr;
- screen[i,j].attr := cursor_color;
- update_screen(I,1);
- gotoxy(1,25);
- textcolor(menu_color);
- write(menu);
- textcolor(counter_color);
- update_menu;
-
- repeat
- CheckInput;
- until UpCase(Ch) = 'X';
- screen[i,j].attr := saveattr;
- textbackground(black);
- update_screen(1,25);
- GOTOXY(cx,cy);
- end;