Home » CEEFAX disks » telesoftware15.adl » 06-05-89/SINE_PAS

06-05-89/SINE_PAS

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » CEEFAX disks » telesoftware15.adl
Filename: 06-05-89/SINE_PAS
Read OK:
File size: 09F9 bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
PROGRAM sinedemo;

{ This program draws a sine wave, using PASPC graphics.

  Date: 8 June 1988
  Copyright (c) 1988 Prospero Software }

{$i paspc}

LABEL
    999 ;
    
CONST
    pi = 3.1415826;

VAR x_max, y_max, centre, height, i, border: integer2;
    scale: real; ch: char ; scan: byte ;

PROCEDURE dodraw ( x1, y1, x2, y2: integer2; color: colorrange ) ;
VAR temppos: integer2;
BEGIN
  CASE adaptor OF
    monoadap : BEGIN
	         gotoxy ( x1, centre );
	         putchar ( chr (196), 80-2*border );
	         FOR temppos := y1 TO y2 DO
	           BEGIN
	             gotoxy ( x1, temppos ); 
	             putchar ( chr (179), 1 );
	           END {for};
	         gotoxy ( x1, centre );
	         putchar ( chr ( 195), 1 );
	       END;
    otherwise draw ( x1, y1, x2, y2, color );
  END {case}
END {dodraw};

PROCEDURE doplot ( x1, y1 : integer2; color: colorrange ) ;
VAR specialchar: char;
BEGIN
  case adaptor of
    monoadap : BEGIN
	         gotoxy (x1, y1);
	         CASE color OF
	           1 : specialchar := '*' ;
	           3 : specialchar := 'o' ;
	           otherwise specialchar := '+' ;
	         END {case};
	         putchar ( specialchar, 1 );
	       END;
    otherwise plot ( x1, y1, color );
  END {case};
END {doplot};

BEGIN { main program }
  initscreen ;
  case adaptor of
    cgadap : BEGIN
	       setscreenmode ( cgahires ) ;
	       cgacolor ( green ) ;
	       x_max := 639;
	       y_max := 199;
	       border := 10;
	     END;
    egadap : BEGIN
	       setscreenmode ( egagraph ) ;
	       x_max := 639;
	       y_max := 349;
	       border := 10;
	     END;
    monoadap : BEGIN
	         x_max := 80;
	         y_max := 25;
	         border := 1;
	       END;
    otherwise GOTO 999;
    END {case};
    
  centre := y_max DIV 2;
  height := centre - border;
  scale := 2 * pi / (x_max - 2*border);
  
  clrscr;
  dodraw(border, border, border, y_max - border, 1);
  IF adaptor <> monoadap THEN
    draw(border, centre, x_max - border, centre, 1);
      
  FOR i := 0 TO x_max - 2*border DO
    BEGIN
      doplot(i + border, trunc (centre + height * sin(i * scale)), 1);
      doplot(i + border, trunc (centre + height * sin(i * scale * 2)), 3);
      IF adaptor <> monoadap THEN
	BEGIN
	  plot(i + border, trunc (centre + height * sin(i * scale * 3)), 5);
	  plot(i + border, trunc (centre + height * sin(i * scale * 4)), 7);
	END;
    END;
  GetKeyboard ( Ch, Scan ) ;
  InitScreen ;
999:
END.

00000000  50 52 4f 47 52 41 4d 20  73 69 6e 65 64 65 6d 6f  |PROGRAM sinedemo|
00000010  3b 0d 0a 0d 0a 7b 20 54  68 69 73 20 70 72 6f 67  |;....{ This prog|
00000020  72 61 6d 20 64 72 61 77  73 20 61 20 73 69 6e 65  |ram draws a sine|
00000030  20 77 61 76 65 2c 20 75  73 69 6e 67 20 50 41 53  | wave, using PAS|
00000040  50 43 20 67 72 61 70 68  69 63 73 2e 0d 0a 0d 0a  |PC graphics.....|
00000050  20 20 44 61 74 65 3a 20  38 20 4a 75 6e 65 20 31  |  Date: 8 June 1|
00000060  39 38 38 0d 0a 20 20 43  6f 70 79 72 69 67 68 74  |988..  Copyright|
00000070  20 28 63 29 20 31 39 38  38 20 50 72 6f 73 70 65  | (c) 1988 Prospe|
00000080  72 6f 20 53 6f 66 74 77  61 72 65 20 7d 0d 0a 0d  |ro Software }...|
00000090  0a 7b 24 69 20 70 61 73  70 63 7d 0d 0a 0d 0a 4c  |.{$i paspc}....L|
000000a0  41 42 45 4c 0d 0a 20 20  20 20 39 39 39 20 3b 0d  |ABEL..    999 ;.|
000000b0  0a 20 20 20 20 0d 0a 43  4f 4e 53 54 0d 0a 20 20  |.    ..CONST..  |
000000c0  20 20 70 69 20 3d 20 33  2e 31 34 31 35 38 32 36  |  pi = 3.1415826|
000000d0  3b 0d 0a 0d 0a 56 41 52  20 78 5f 6d 61 78 2c 20  |;....VAR x_max, |
000000e0  79 5f 6d 61 78 2c 20 63  65 6e 74 72 65 2c 20 68  |y_max, centre, h|
000000f0  65 69 67 68 74 2c 20 69  2c 20 62 6f 72 64 65 72  |eight, i, border|
00000100  3a 20 69 6e 74 65 67 65  72 32 3b 0d 0a 20 20 20  |: integer2;..   |
00000110  20 73 63 61 6c 65 3a 20  72 65 61 6c 3b 20 63 68  | scale: real; ch|
00000120  3a 20 63 68 61 72 20 3b  20 73 63 61 6e 3a 20 62  |: char ; scan: b|
00000130  79 74 65 20 3b 0d 0a 0d  0a 50 52 4f 43 45 44 55  |yte ;....PROCEDU|
00000140  52 45 20 64 6f 64 72 61  77 20 28 20 78 31 2c 20  |RE dodraw ( x1, |
00000150  79 31 2c 20 78 32 2c 20  79 32 3a 20 69 6e 74 65  |y1, x2, y2: inte|
00000160  67 65 72 32 3b 20 63 6f  6c 6f 72 3a 20 63 6f 6c  |ger2; color: col|
00000170  6f 72 72 61 6e 67 65 20  29 20 3b 0d 0a 56 41 52  |orrange ) ;..VAR|
00000180  20 74 65 6d 70 70 6f 73  3a 20 69 6e 74 65 67 65  | temppos: intege|
00000190  72 32 3b 0d 0a 42 45 47  49 4e 0d 0a 20 20 43 41  |r2;..BEGIN..  CA|
000001a0  53 45 20 61 64 61 70 74  6f 72 20 4f 46 0d 0a 20  |SE adaptor OF.. |
000001b0  20 20 20 6d 6f 6e 6f 61  64 61 70 20 3a 20 42 45  |   monoadap : BE|
000001c0  47 49 4e 0d 0a 09 20 20  20 20 20 20 20 20 20 67  |GIN...         g|
000001d0  6f 74 6f 78 79 20 28 20  78 31 2c 20 63 65 6e 74  |otoxy ( x1, cent|
000001e0  72 65 20 29 3b 0d 0a 09  20 20 20 20 20 20 20 20  |re );...        |
000001f0  20 70 75 74 63 68 61 72  20 28 20 63 68 72 20 28  | putchar ( chr (|
00000200  31 39 36 29 2c 20 38 30  2d 32 2a 62 6f 72 64 65  |196), 80-2*borde|
00000210  72 20 29 3b 0d 0a 09 20  20 20 20 20 20 20 20 20  |r );...         |
00000220  46 4f 52 20 74 65 6d 70  70 6f 73 20 3a 3d 20 79  |FOR temppos := y|
00000230  31 20 54 4f 20 79 32 20  44 4f 0d 0a 09 20 20 20  |1 TO y2 DO...   |
00000240  20 20 20 20 20 20 20 20  42 45 47 49 4e 0d 0a 09  |        BEGIN...|
00000250  20 20 20 20 20 20 20 20  20 20 20 20 20 67 6f 74  |             got|
00000260  6f 78 79 20 28 20 78 31  2c 20 74 65 6d 70 70 6f  |oxy ( x1, temppo|
00000270  73 20 29 3b 20 0d 0a 09  20 20 20 20 20 20 20 20  |s ); ...        |
00000280  20 20 20 20 20 70 75 74  63 68 61 72 20 28 20 63  |     putchar ( c|
00000290  68 72 20 28 31 37 39 29  2c 20 31 20 29 3b 0d 0a  |hr (179), 1 );..|
000002a0  09 20 20 20 20 20 20 20  20 20 20 20 45 4e 44 20  |.           END |
000002b0  7b 66 6f 72 7d 3b 0d 0a  09 20 20 20 20 20 20 20  |{for};...       |
000002c0  20 20 67 6f 74 6f 78 79  20 28 20 78 31 2c 20 63  |  gotoxy ( x1, c|
000002d0  65 6e 74 72 65 20 29 3b  0d 0a 09 20 20 20 20 20  |entre );...     |
000002e0  20 20 20 20 70 75 74 63  68 61 72 20 28 20 63 68  |    putchar ( ch|
000002f0  72 20 28 20 31 39 35 29  2c 20 31 20 29 3b 0d 0a  |r ( 195), 1 );..|
00000300  09 20 20 20 20 20 20 20  45 4e 44 3b 0d 0a 20 20  |.       END;..  |
00000310  20 20 6f 74 68 65 72 77  69 73 65 20 64 72 61 77  |  otherwise draw|
00000320  20 28 20 78 31 2c 20 79  31 2c 20 78 32 2c 20 79  | ( x1, y1, x2, y|
00000330  32 2c 20 63 6f 6c 6f 72  20 29 3b 0d 0a 20 20 45  |2, color );..  E|
00000340  4e 44 20 7b 63 61 73 65  7d 0d 0a 45 4e 44 20 7b  |ND {case}..END {|
00000350  64 6f 64 72 61 77 7d 3b  0d 0a 0d 0a 50 52 4f 43  |dodraw};....PROC|
00000360  45 44 55 52 45 20 64 6f  70 6c 6f 74 20 28 20 78  |EDURE doplot ( x|
00000370  31 2c 20 79 31 20 3a 20  69 6e 74 65 67 65 72 32  |1, y1 : integer2|
00000380  3b 20 63 6f 6c 6f 72 3a  20 63 6f 6c 6f 72 72 61  |; color: colorra|
00000390  6e 67 65 20 29 20 3b 0d  0a 56 41 52 20 73 70 65  |nge ) ;..VAR spe|
000003a0  63 69 61 6c 63 68 61 72  3a 20 63 68 61 72 3b 0d  |cialchar: char;.|
000003b0  0a 42 45 47 49 4e 0d 0a  20 20 63 61 73 65 20 61  |.BEGIN..  case a|
000003c0  64 61 70 74 6f 72 20 6f  66 0d 0a 20 20 20 20 6d  |daptor of..    m|
000003d0  6f 6e 6f 61 64 61 70 20  3a 20 42 45 47 49 4e 0d  |onoadap : BEGIN.|
000003e0  0a 09 20 20 20 20 20 20  20 20 20 67 6f 74 6f 78  |..         gotox|
000003f0  79 20 28 78 31 2c 20 79  31 29 3b 0d 0a 09 20 20  |y (x1, y1);...  |
00000400  20 20 20 20 20 20 20 43  41 53 45 20 63 6f 6c 6f  |       CASE colo|
00000410  72 20 4f 46 0d 0a 09 20  20 20 20 20 20 20 20 20  |r OF...         |
00000420  20 20 31 20 3a 20 73 70  65 63 69 61 6c 63 68 61  |  1 : specialcha|
00000430  72 20 3a 3d 20 27 2a 27  20 3b 0d 0a 09 20 20 20  |r := '*' ;...   |
00000440  20 20 20 20 20 20 20 20  33 20 3a 20 73 70 65 63  |        3 : spec|
00000450  69 61 6c 63 68 61 72 20  3a 3d 20 27 6f 27 20 3b  |ialchar := 'o' ;|
00000460  0d 0a 09 20 20 20 20 20  20 20 20 20 20 20 6f 74  |...           ot|
00000470  68 65 72 77 69 73 65 20  73 70 65 63 69 61 6c 63  |herwise specialc|
00000480  68 61 72 20 3a 3d 20 27  2b 27 20 3b 0d 0a 09 20  |har := '+' ;... |
00000490  20 20 20 20 20 20 20 20  45 4e 44 20 7b 63 61 73  |        END {cas|
000004a0  65 7d 3b 0d 0a 09 20 20  20 20 20 20 20 20 20 70  |e};...         p|
000004b0  75 74 63 68 61 72 20 28  20 73 70 65 63 69 61 6c  |utchar ( special|
000004c0  63 68 61 72 2c 20 31 20  29 3b 0d 0a 09 20 20 20  |char, 1 );...   |
000004d0  20 20 20 20 45 4e 44 3b  0d 0a 20 20 20 20 6f 74  |    END;..    ot|
000004e0  68 65 72 77 69 73 65 20  70 6c 6f 74 20 28 20 78  |herwise plot ( x|
000004f0  31 2c 20 79 31 2c 20 63  6f 6c 6f 72 20 29 3b 0d  |1, y1, color );.|
00000500  0a 20 20 45 4e 44 20 7b  63 61 73 65 7d 3b 0d 0a  |.  END {case};..|
00000510  45 4e 44 20 7b 64 6f 70  6c 6f 74 7d 3b 0d 0a 0d  |END {doplot};...|
00000520  0a 42 45 47 49 4e 20 7b  20 6d 61 69 6e 20 70 72  |.BEGIN { main pr|
00000530  6f 67 72 61 6d 20 7d 0d  0a 20 20 69 6e 69 74 73  |ogram }..  inits|
00000540  63 72 65 65 6e 20 3b 0d  0a 20 20 63 61 73 65 20  |creen ;..  case |
00000550  61 64 61 70 74 6f 72 20  6f 66 0d 0a 20 20 20 20  |adaptor of..    |
00000560  63 67 61 64 61 70 20 3a  20 42 45 47 49 4e 0d 0a  |cgadap : BEGIN..|
00000570  09 20 20 20 20 20 20 20  73 65 74 73 63 72 65 65  |.       setscree|
00000580  6e 6d 6f 64 65 20 28 20  63 67 61 68 69 72 65 73  |nmode ( cgahires|
00000590  20 29 20 3b 0d 0a 09 20  20 20 20 20 20 20 63 67  | ) ;...       cg|
000005a0  61 63 6f 6c 6f 72 20 28  20 67 72 65 65 6e 20 29  |acolor ( green )|
000005b0  20 3b 0d 0a 09 20 20 20  20 20 20 20 78 5f 6d 61  | ;...       x_ma|
000005c0  78 20 3a 3d 20 36 33 39  3b 0d 0a 09 20 20 20 20  |x := 639;...    |
000005d0  20 20 20 79 5f 6d 61 78  20 3a 3d 20 31 39 39 3b  |   y_max := 199;|
000005e0  0d 0a 09 20 20 20 20 20  20 20 62 6f 72 64 65 72  |...       border|
000005f0  20 3a 3d 20 31 30 3b 0d  0a 09 20 20 20 20 20 45  | := 10;...     E|
00000600  4e 44 3b 0d 0a 20 20 20  20 65 67 61 64 61 70 20  |ND;..    egadap |
00000610  3a 20 42 45 47 49 4e 0d  0a 09 20 20 20 20 20 20  |: BEGIN...      |
00000620  20 73 65 74 73 63 72 65  65 6e 6d 6f 64 65 20 28  | setscreenmode (|
00000630  20 65 67 61 67 72 61 70  68 20 29 20 3b 0d 0a 09  | egagraph ) ;...|
00000640  20 20 20 20 20 20 20 78  5f 6d 61 78 20 3a 3d 20  |       x_max := |
00000650  36 33 39 3b 0d 0a 09 20  20 20 20 20 20 20 79 5f  |639;...       y_|
00000660  6d 61 78 20 3a 3d 20 33  34 39 3b 0d 0a 09 20 20  |max := 349;...  |
00000670  20 20 20 20 20 62 6f 72  64 65 72 20 3a 3d 20 31  |     border := 1|
00000680  30 3b 0d 0a 09 20 20 20  20 20 45 4e 44 3b 0d 0a  |0;...     END;..|
00000690  20 20 20 20 6d 6f 6e 6f  61 64 61 70 20 3a 20 42  |    monoadap : B|
000006a0  45 47 49 4e 0d 0a 09 20  20 20 20 20 20 20 20 20  |EGIN...         |
000006b0  78 5f 6d 61 78 20 3a 3d  20 38 30 3b 0d 0a 09 20  |x_max := 80;... |
000006c0  20 20 20 20 20 20 20 20  79 5f 6d 61 78 20 3a 3d  |        y_max :=|
000006d0  20 32 35 3b 0d 0a 09 20  20 20 20 20 20 20 20 20  | 25;...         |
000006e0  62 6f 72 64 65 72 20 3a  3d 20 31 3b 0d 0a 09 20  |border := 1;... |
000006f0  20 20 20 20 20 20 45 4e  44 3b 0d 0a 20 20 20 20  |      END;..    |
00000700  6f 74 68 65 72 77 69 73  65 20 47 4f 54 4f 20 39  |otherwise GOTO 9|
00000710  39 39 3b 0d 0a 20 20 20  20 45 4e 44 20 7b 63 61  |99;..    END {ca|
00000720  73 65 7d 3b 0d 0a 20 20  20 20 0d 0a 20 20 63 65  |se};..    ..  ce|
00000730  6e 74 72 65 20 3a 3d 20  79 5f 6d 61 78 20 44 49  |ntre := y_max DI|
00000740  56 20 32 3b 0d 0a 20 20  68 65 69 67 68 74 20 3a  |V 2;..  height :|
00000750  3d 20 63 65 6e 74 72 65  20 2d 20 62 6f 72 64 65  |= centre - borde|
00000760  72 3b 0d 0a 20 20 73 63  61 6c 65 20 3a 3d 20 32  |r;..  scale := 2|
00000770  20 2a 20 70 69 20 2f 20  28 78 5f 6d 61 78 20 2d  | * pi / (x_max -|
00000780  20 32 2a 62 6f 72 64 65  72 29 3b 0d 0a 20 20 0d  | 2*border);..  .|
00000790  0a 20 20 63 6c 72 73 63  72 3b 0d 0a 20 20 64 6f  |.  clrscr;..  do|
000007a0  64 72 61 77 28 62 6f 72  64 65 72 2c 20 62 6f 72  |draw(border, bor|
000007b0  64 65 72 2c 20 62 6f 72  64 65 72 2c 20 79 5f 6d  |der, border, y_m|
000007c0  61 78 20 2d 20 62 6f 72  64 65 72 2c 20 31 29 3b  |ax - border, 1);|
000007d0  0d 0a 20 20 49 46 20 61  64 61 70 74 6f 72 20 3c  |..  IF adaptor <|
000007e0  3e 20 6d 6f 6e 6f 61 64  61 70 20 54 48 45 4e 0d  |> monoadap THEN.|
000007f0  0a 20 20 20 20 64 72 61  77 28 62 6f 72 64 65 72  |.    draw(border|
00000800  2c 20 63 65 6e 74 72 65  2c 20 78 5f 6d 61 78 20  |, centre, x_max |
00000810  2d 20 62 6f 72 64 65 72  2c 20 63 65 6e 74 72 65  |- border, centre|
00000820  2c 20 31 29 3b 0d 0a 20  20 20 20 20 20 0d 0a 20  |, 1);..      .. |
00000830  20 46 4f 52 20 69 20 3a  3d 20 30 20 54 4f 20 78  | FOR i := 0 TO x|
00000840  5f 6d 61 78 20 2d 20 32  2a 62 6f 72 64 65 72 20  |_max - 2*border |
00000850  44 4f 0d 0a 20 20 20 20  42 45 47 49 4e 0d 0a 20  |DO..    BEGIN.. |
00000860  20 20 20 20 20 64 6f 70  6c 6f 74 28 69 20 2b 20  |     doplot(i + |
00000870  62 6f 72 64 65 72 2c 20  74 72 75 6e 63 20 28 63  |border, trunc (c|
00000880  65 6e 74 72 65 20 2b 20  68 65 69 67 68 74 20 2a  |entre + height *|
00000890  20 73 69 6e 28 69 20 2a  20 73 63 61 6c 65 29 29  | sin(i * scale))|
000008a0  2c 20 31 29 3b 0d 0a 20  20 20 20 20 20 64 6f 70  |, 1);..      dop|
000008b0  6c 6f 74 28 69 20 2b 20  62 6f 72 64 65 72 2c 20  |lot(i + border, |
000008c0  74 72 75 6e 63 20 28 63  65 6e 74 72 65 20 2b 20  |trunc (centre + |
000008d0  68 65 69 67 68 74 20 2a  20 73 69 6e 28 69 20 2a  |height * sin(i *|
000008e0  20 73 63 61 6c 65 20 2a  20 32 29 29 2c 20 33 29  | scale * 2)), 3)|
000008f0  3b 0d 0a 20 20 20 20 20  20 49 46 20 61 64 61 70  |;..      IF adap|
00000900  74 6f 72 20 3c 3e 20 6d  6f 6e 6f 61 64 61 70 20  |tor <> monoadap |
00000910  54 48 45 4e 0d 0a 09 42  45 47 49 4e 0d 0a 09 20  |THEN...BEGIN... |
00000920  20 70 6c 6f 74 28 69 20  2b 20 62 6f 72 64 65 72  | plot(i + border|
00000930  2c 20 74 72 75 6e 63 20  28 63 65 6e 74 72 65 20  |, trunc (centre |
00000940  2b 20 68 65 69 67 68 74  20 2a 20 73 69 6e 28 69  |+ height * sin(i|
00000950  20 2a 20 73 63 61 6c 65  20 2a 20 33 29 29 2c 20  | * scale * 3)), |
00000960  35 29 3b 0d 0a 09 20 20  70 6c 6f 74 28 69 20 2b  |5);...  plot(i +|
00000970  20 62 6f 72 64 65 72 2c  20 74 72 75 6e 63 20 28  | border, trunc (|
00000980  63 65 6e 74 72 65 20 2b  20 68 65 69 67 68 74 20  |centre + height |
00000990  2a 20 73 69 6e 28 69 20  2a 20 73 63 61 6c 65 20  |* sin(i * scale |
000009a0  2a 20 34 29 29 2c 20 37  29 3b 0d 0a 09 45 4e 44  |* 4)), 7);...END|
000009b0  3b 0d 0a 20 20 20 20 45  4e 44 3b 0d 0a 20 20 47  |;..    END;..  G|
000009c0  65 74 4b 65 79 62 6f 61  72 64 20 28 20 43 68 2c  |etKeyboard ( Ch,|
000009d0  20 53 63 61 6e 20 29 20  3b 0d 0a 20 20 49 6e 69  | Scan ) ;..  Ini|
000009e0  74 53 63 72 65 65 6e 20  3b 0d 0a 39 39 39 3a 0d  |tScreen ;..999:.|
000009f0  0a 45 4e 44 2e 0d 0a 0d  0a                       |.END.....|
000009f9
06-05-89/SINE_PAS.m0
06-05-89/SINE_PAS.m1
06-05-89/SINE_PAS.m2
06-05-89/SINE_PAS.m4
06-05-89/SINE_PAS.m5