Metropoli BBS
VIEWER: progp.pas MODE: TEXT (ASCII)

{**********************************************************************}
{ This is a main routine which is used to test all the functions        }
{ provided in the examples.  This program allows the operator to        }
{ select the function to be demonstrated and will call the appropriate  }
{ sample routine.  To quit select any number outside the range.         }
{**********************************************************************}
{**********************************************************************}
{ This is a main routine which is used to test all the functions        }
{ provided in the examples.  This program allows the operator to        }
{ select the function to be demonstrated and will call the approriate   }
{ sample routine.  To quit select any number outside the displayed      }
{ range                                                                 }
{**********************************************************************}

program select_demo;
uses egalibp,crt;
const
MAX_PROC = 52;
ESC = $1B;
CR = $0d;
text_table : array[0..51,0..39] of char = (
                'Use Write_Reg to set cursor start to 1  ',
                'Use Write_Palette to reverse video      ',
                'Use Write_Reg_Set to set video mode     ',
                'Write_Reg & Read_Reg to read cursor addr',
                'Use Read_Reg to read feature bits       ',
                'Write_Reg & Read_Reg to read switches   ',
                'Find refresh rate by timing Vert Retrace',
                'Smooth horiz scroll (use arrow keys)    ',
                'Smooth vertical scroll (use arrow keys) ',
                'Scroll text                             ',
                'Scroll page                             ',
                'Clear Screen (fill memory)              ',
                'Call BIOS Video Services (print string) ',
                'Set Mode                                ',
                'Get Mode                                ',
                'Get number of text Rows and Columns     ',
                'Get Cursor Size                         ',
                'Get Page Size                           ',
                'Get Display Type                        ',
                'Get number of horizontal scanlines      ',
                'Get Memory Size                         ',
                'Get Primary Display Type                ',
                'Find if a secondary adapter is present  ',
                'Set Cursor Position                     ',
                'Get Cursor Position                     ',
                'Set Cursor Size                         ',
                'Write character                         ',
                'Write attribute                         ',
                'Write blinking text                     ',
                'Write String                            ',
                'Italicize character set                 ',
                'Redefine letter A                       ',
                'Load 512 character set                  ',
                'Split Screen (use arrow keys)           ',
                'Set 43 text lines                       ',
                'Draw text boxes                         ',
                'Smooth text scroll (use arrow keys)     ',
                'Read characters                         ',
                'Read Attributes                         ',
                'Write Pixels (draw 16 boxes)            ',
                'Use Scanline Fill to fill a triangle    ',
                'Draw Solid Boxes                        ',
                'Draw Radial Lines                       ',
                'Draw Slow Radial Lines                  ',
                'Draw moving lines                       ',
                'Draw Patterned Triangle                 ',
                'Draw Checkered Box                      ',
                'Draw Arc                                ',
                'Do BITBLT                               ',
                'Show Graphics Cursor (use arrow keys)   ',
                'Save screen to file PICTURE.xxx         ',
                'Load Screen from file PICTURE.xxx       '
                );

var
select, i,j,c : integer;
buffer : array[0..9] of char;

{$I progp001.pas}
{$I progp002.pas}
{$I progp003.pas}
{$I progp004.pas}
{$I progp005.pas}
{$I progp006.pas}
{$I progp007.pas}
{$I progp009.pas}
{$I progp010.pas}
{$I progp011.pas}
{$I progp012.pas}
{$I progp014.pas}
{$I progp020.pas}
{$I progp022.pas}
{$I progp024.pas}
{$I progp025.pas}
{$I progp027.pas}
{$I progp028.pas}
{$I progp029.pas}
{$I progp030.pas}
{$I progp032.pas}
{$I progp040.pas}
{$I progp041.pas}
{$I progp042.pas}
{$I progp043.pas}
{$I progp044.pas}
{$I progp045.pas}
{$I progp046.pas}
{$I progp047.pas}
{$I progp048.pas}
{$I progp049.pas}
{$I progp050.pas}
{$I progp051.pas}
{$I progp052.pas}
{$I progp053.pas}
{$I progp054.pas}
{$I progp055.pas}
{$I progp056.pas}
{$I progp057.pas}
{$I progp080.pas}
{$I progp082.pas}
{$I progp083.pas}
{$I progp085.pas}
{$I progp086.pas}
{$I progp084.pas}
{$I progp088.pas}
{$I progp087.pas}
{$I progp090.pas}
{$I progp089.pas}
{$I progp091.pas}
{$I progp092.pas}
{$I progp093.pas}
{$I progp094.pas}


{**********************************************************************}
{ Copy a 100,100 block from upper left corner of the screen             }
{ and move it successively 10 times, two pixels at a time               }
{**********************************************************************}

procedure slide_block;
const
MONO = 5;
COLOR = 4;
VMONO = 7;
COPY = 0;
txt : array[0..25] of char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var
i,j : integer;
begin
        clear_screen;
        i := get_display_type;
        if i = MONO then set_mode($0F)
        else if i = VMONO then set_mode($0F)
        else if i = COLOR then set_mode($0E)
        else set_mode($10);

        for i := 1 to 50 do     { Fill screen with some data    }
            for j := 0 to 25 do video_BIOS($E00 + integer(txt[j]),7,0,0,0,0);

        for i := 1 to 5 do     { Copy next block       }
                slow_bitblt(0,0, 320+(i shl 2), i shl 2, 100, 100, COPY);

        i := integer(readkey);
        {--- Set default text mode                                      }
        i := get_display_type;
        if i = MONO then set_mode(7)
        else if i = VMONO then set_mode(7)
        else    set_mode(3);
end;

{**********************************************************************}
{ Draw a moving line in each quadrant of the screen.  Each of the       }
{ four lines has a different color and the endpoints of the line will   }
{ 'bounce' off the edges of the corresponding quadrant.                 }
{**********************************************************************}

procedure lines_demo;
const
MONO = 5;
COLOR = 4;
VMONO = 7;
M = 100;
N = 10;
MAXX = 319;
MAXY = 174;             { Change this to 100 for Color Monitor }
var
c1,c2,c3,c4,i,j,k,l,q : integer;
p : array[0..3] of integer;
d : array[0..3] of integer;
x0,y0,x1,y1 : longint;
begin
        clear_screen;
        i := get_display_type;
        if i = MONO then set_mode($0F)
        else if i = VMONO then set_mode($0F)
        else if i = COLOR then set_mode($0E)
        else set_mode($10);

        c1 := 8;
        c2 := 9;
        c3 := 10;
        c4 := 11;
        clear_screen;                   { Clear screen                  }

        {**************************************************************}
        { start a next set of four lines, picking semirandom starting   }
        { point at p and moving with speed d.                           }
        {**************************************************************}

        while not KeyPressed do
              begin
              x0 := ticks;
              x1 := ticks*33;
              y0 := ticks*23;
              y1 := ticks*7;
              p[0] := x1 and 255;   {initial points of the line}
              p[1] := y0 and 127;
              p[2] := p[0] + 75 + (p[0] and 7);
              p[3] := p[1] + 15 + (p[0] and 7);
              d[0] := (5 + x0) and 7;              {initial motion vector }
              d[1] := (7 + x1) and 7;
              d[2] := (5 + y0) and 7;
              d[3] := (7 + y1) and 7;
              clear_screen;

              { pick four semirandom colors }
              if ((get_display_type = MONO) or (get_display_type = VMONO)) then
                 begin
                 c1 := 15;
                 c2 := 15;
                 c3 := 15;
                 c4 := 15;
                 end
              else
                  begin
                  c1 := (c1+1) and 15;
                  if c1 = 13 then c1 := 8;
                  c2 := c1 + 1;
                  c3 := c1 + 2;
                  c4 := c1 + 3;
                  end;

        {**************************************************************}
        { draw the line (and the three mirror images) and then compute  }
        { new position                                                  }
        {**************************************************************}
                q := 0;
                while (q < M) and not KeyPressed do
                        begin
                        if KeyPressed then q := M;
                        inc(q);
                        i := p[0];
                        j := p[1];
                        k := p[2];
                        l := p[3];
                        line(i,j,k,l,c1);

                        i := 639 - i;
                        k := 639 - k;
                        line(i,j,k,l,c2);

                        j := 349 - j;
                        l := 349 - l;
                        line(i,j,k,l,c3);

                        i := 639 - i;
                        k := 639 - k;
                        line(i,j,k,l,c4);

{**************************************************************}
{ update two end points of a line (four coordinates) with the   }
{ values specified in d.  Should the resulting points fall      }
{ outside the bounds, 'bounce' them off the sides.              }
{**************************************************************}
                        {reverse motion if lines fall outside the bounds }
                        if (p[0] + d[0]) < 0 then d[0] := -d[0];
                        if (p[0] + d[0]) > MAXX then d[0] := -d[0];
                        if (p[1] + d[1]) < 0 then d[1] := -d[1];
                        if (p[1] + d[1]) > MAXY then d[1] := -d[1];
                        if (p[2] + d[2]) < 0 then d[2] := -d[2];
                        if (p[2] + d[2]) > MAXX then d[2] := -d[2];
                        if (p[3] + d[3]) < 0 then d[3] := -d[3];
                        if (p[3] + d[3]) > MAXY then d[3] := -d[3];
                        {compute next endpoints of the line }
                        for i := 0 to 3 do p[i] := p[i] + d[i];
                        end;
                x0 := ticks;
                while ticks - x0 < 18 do begin end;     {Take a rest}
                end;

        i := integer(readkey);

        {--- Set default text mode                                      }

        i := get_display_type;
        if i = MONO then set_mode(7)
        else if i = VMONO then set_mode(7)
        else    set_mode(3);
end;

begin
{**************************************************************}
{ Here we print all prompts and user selects which routine      }
{ to do next.   -1 to list, 0 to do all,  out of range to quit  }
{**************************************************************}

        select := 0;
        repeat
                if select < 0 then for j := 0 to MAX_PROC-1 do
                begin
                        writeln(j+1,': ',text_table[j]);
                        if j = 20 then c := integer(readkey);
                        if j = 40 then c := integer(readkey);
                end;
                writeln('Enter test (0 = all, -1 = list, 99 = quit):');
                read (select);
        until select >= 0;

        {******************************************************}
        { Loop throgh all the samples one a time and wait for   }
        { Enter key to be pressed at the start of each sample   }
        { and after each sample is done.                        }
        {******************************************************}
        if select = 0 then inc(select);
        if select <= MAX_PROC then for i := select-1 to MAX_PROC-1 do
        begin
                while keypressed = TRUE do c := integer(readkey);
                set_cursor_position(24,0);
                writeln(i+1,': Press <Enter> to ',text_table[i]);
                repeat
                c := integer(readkey);
                if c = ESC then i := MAX_PROC;
                until c = CR;
                case i+1 of

                1 : write_curs_start;
                2 : invert_B_n_W;
                3 : select_mode_x;
                4 : read_cursor_address;
                5 : read_feature;
                6 : read_switches;
                7 : wait_4_vert;
                8 : smooth_horizontal;
                9 : smooth_vertical;
                10 : sample_scroll_text;
                11 : sample_scroll_page;
                12 : cls;
                13 : test_video_BIOS;
                14 : test_set_mode;
                15 : print_mode;
                16 : print_rows_cols;
                17 : print_cursor_size;
                18 : print_page_size;
                19 : print_display_type;
                20 : print_scanlines;
                21 : print_memory_size;
                22 : print_primary;
                23 : print_if_second;
                24 : cursor_in_middle;
                25 : print_cursor_pos;
                26 : demo_cursor_size;
                27 : write_one_char;
                28 : make_reverse;
                29 : demo_text_blink;
                30 : print_hello;
                31 : italicize;
                32 : replace_a;
                33 : print_512_chars;
                34 : demo_split_screen;
                35 : demo_43_lines;
                36 : boxed_hello;
                37 : smooth_text_scroll;
                38 : print_10_chars;
                39 : print_10_attr;
                40 : pixel_box16;
                41 : fill_triag;
                42 : solid_box16;
                43 : radial_lines;
                44 : slow_radial_lines;
                45 : lines_demo;
                46 : pattern_triag;
                47 : checkers;
                48 : arc_demo;
                49 : slide_block;
                50 : demo_cursor;
                51 : save_screen;
                52 : restore_screen;
                end;
                c := integer(readkey);
        end;

end.

[ RETURN TO DIRECTORY ]