Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / int / graf / gpmap.c
1 \r
2 #include "graf.h"
3
4      /* Loglan82 Compiler&Interpreter\r
5      Copyright (C) 1981-1993 Institute of Informatics, University of Warsaw\r
6      Copyright (C)  1993, 1994 LITA, Pau\r
7      \r
8      This program is free software; you can redistribute it and/or modify\r
9      it under the terms of the GNU General Public License as published by\r
10      the Free Software Foundation; either version 2 of the License, or\r
11      (at your option) any later version.\r
12      \r
13      This program is distributed in the hope that it will be useful,\r
14      but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16      GNU General Public License for more details.\r
17      \r
18 =======================================================================\r
19 */\r
20
21 void pascal getmap( x, y, buf )
22    int *x,*y;
23    char *buf;
24 {
25  /* buffer : 2 bytes X size, 2 bytes Y size, and rows * columns of pixels */
26    int i,j,x0,y0,x1,y1;
27    int x00 = inxpos(NULL);
28    int y00 = inypos(NULL);
29    pushxy();
30    if( *x < x00 )
31    {
32       x0 = *x;
33       x1 = x00;
34    }
35    else
36    {
37       x1 = *x;
38       x0 = x00;
39    }
40    if( *y < y00 )
41    {
42       y0 = *y;
43       y1 = y00;
44    }
45    else
46    {
47       y1 = *y;
48       y0 = y00;
49    }
50    ((short int *)buf)[0] = (short int)(x1-x0+1);
51    ((short int *)buf)[1] = (short int)(y1-y0+1);
52    buf += 4;
53    for( j=y0; j<=y1; j++ )
54       for( i=x0; i<=x1; i++ )
55          *(buf++) = (char)inpix( &i, &j );
56    popxy();
57 }
58
59
60 void pascal putmap( buf )
61    char *buf;
62 {
63    int x00 = inxpos(NULL);
64    int y00 = inypos(NULL);
65    int xw = ((short int *)buf)[0];
66    int yw = ((short int *)buf)[1];
67    int i,j;
68    pushxy();
69    buf += 4;
70    for( j=y00; j<y00+yw; j++ )
71       for( i=x00; i<x00+xw; i++ )
72       {
73          int c = (int)*buf;
74          color( &c );
75          point( &i, &j );
76          buf++;
77       }
78    popxy();
79 }
80
81
82 void pascal  ormap( buf )
83    char *buf;
84 {
85    int x00 = inxpos(NULL);
86    int y00 = inypos(NULL);
87    int xw = ((short int *)buf)[0];
88    int yw = ((short int *)buf)[1];
89    int i,j;
90    pushxy();
91    buf += 4;
92    for( j=y00; j<y00+yw; j++ )
93       for( i=x00; i<x00+xw; i++ )
94       {
95          int c = inpix( &i, &j );
96          c |= (int)*buf;
97          color( &c );
98          point( &i, &j );
99          buf++;
100       }
101    popxy();
102 }
103
104
105 void pascal xormap( buf )
106    char *buf;
107 {
108    int x00 = inxpos(NULL);
109    int y00 = inypos(NULL);
110    int xw = ((short int *)buf)[0];
111    int yw = ((short int *)buf)[1];
112    int i,j;
113    pushxy();
114    buf += 4;
115    for( j=y00; j<y00+yw; j++ )
116       for( i=x00; i<x00+xw; i++ )
117       {
118          int c = inpix( &i, &j );
119          c ^= (int)*buf;
120          color( &c );
121          point( &i, &j );
122          buf++;
123       }
124    popxy();
125 }
126         
127
128 \r