home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / mouse.swg / 0015_Mouse Cursor Editor.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-01-27  |  3.3 KB  |  172 lines

  1. {
  2. Now here's the source for the Mouse-Cursor-Editor
  3.  
  4. }
  5. PROGRAM Mouse_Edit;
  6. uses Crt;
  7. type
  8.  Masktype = array[1..16] of word;
  9. var
  10.  Cursor :  Array[1..2] of Masktype;
  11.  screenmask,Cursormask : Array [1..16,1..16] of Char;
  12.  x,y,oldx,oldy : Byte;
  13.  Fenster : Boolean; {False=Links,True=Rechts}
  14.  i,j : Byte;
  15.  c : Char;
  16.  wert : word;
  17.   dest : text;
  18.   s : string;
  19.  
  20. procedure Init;
  21. begin
  22.   TextMode (co40);
  23.  ClrScr;
  24.  for i:=1 to 16 do
  25.   for j:=1 to 16 do
  26.   begin
  27.    Screenmask[i,j]:='*';
  28.    GoToXY(i+2,j);
  29.    Write (Screenmask[i,j]);
  30.    CursorMask[i,j]:='.';
  31.    GoToXY (i+22,j);
  32.    Write (CursorMask[i,j]);
  33.   end;
  34.  x:=8; oldx:=8; y:=8; oldy:=8;
  35.  Fenster := false;
  36.  GotoXY(20,20); write('X=',x:3,'  Y=',y:3);
  37.  GotoXY (x+2,y);
  38. end;
  39. procedure Changemask;
  40. var
  41.  t : byte;
  42. begin
  43.  t:=x; x:=oldx; oldx:=t;
  44.  t:=y; y:=oldy; oldy:=t;
  45.  fenster := fenster xor true;
  46.  GotoXY(20,20); write('X=',x:3,'  Y=',y:3);
  47. end;
  48. begin
  49.  init;
  50.  repeat
  51.   c:=readkey;
  52.   if c=#9 then
  53.    ChangeMask
  54.   else if c=#32 then
  55.    if fenster then begin
  56.     if cursormask[x,y]='.' then
  57.      cursormask[x,y]:='*'
  58.     else
  59.      cursormask[x,y]:='.';
  60.     write(cursormask[x,y]);
  61.     GotoXY(wherex-1,wherey);
  62.    end else begin
  63.     if screenmask[x,y]='.' then
  64.      screenmask[x,y]:='*'
  65.     else
  66.      screenmask[x,y]:='.';
  67.     write(screenmask[x,y]);
  68.     GotoXY(wherex-1,wherey)
  69.   end else if c=#0 then begin
  70.    c:=readkey;
  71.    case c of
  72.     #72 : if y > 1 then
  73.         dec(y);
  74.     #80 : if y < 16 then
  75.         inc(y);
  76.     #77 : if x<16 then
  77.         inc(x);
  78.     #75 : if x > 1 then
  79.         dec(x);
  80.    end;
  81.    GotoXY(20,20); write('X=',x:3,'  Y=',y:3);
  82.   end;
  83.   if fenster then
  84.    GotoXY(x+22,y)
  85.   else
  86.    GotoXY(x+2,y);
  87.  until c=#27;
  88.  for i:=1 to 16 do begin
  89.   wert:=0;
  90.   for j:=1 to 16 do
  91.    if screenmask[j,i]='*' then
  92.     inc(wert,1 shl (16-j));
  93.   Cursor[1,i]:=wert;
  94.  end;
  95.  for i:=1 to 16 do begin
  96.   wert:=0;
  97.   for j:=1 to 16 do
  98.    if cursormask[j,i]='*' then
  99.     inc(wert,1 shl (16-j));
  100.   Cursor[2,i]:=wert;
  101.  end;
  102.   assign(dest,'pfeil.dat');
  103.   rewrite(dest);
  104.   writeln (dest,'const');
  105.   write (dest,#7,'screenmask : masktype = (');
  106.   for i:=1 to 16 do begin
  107.    str(cursor[1,i],s);
  108.    write(dest,s);
  109.     if i<16 then
  110.      write(dest,',');
  111.   end;
  112.   writeln(dest,');');
  113.   write (dest,#7,'cursormask : masktype = (');
  114.   for i:=1 to 16 do begin
  115.    str(cursor[2,i],s);
  116.    write(dest,s);
  117.     if i<16 then
  118.      write(dest,',');
  119.   end;
  120.   writeln(dest,');');
  121.  close(dest);
  122. end.
  123.  
  124. {
  125. TORSTEN PINKERT
  126.  
  127. And now here's the program to test how Mouse-Edit works...
  128. }
  129. PROGRAM Mouse_Edit_Test;
  130. uses graph;
  131. type
  132.  masktype = array[1..16] of word;
  133.  
  134. {$I Pfeil.dat}
  135.  
  136. var
  137.  cursor : array[1..2] of masktype;
  138.   gd,gm : integer;
  139.  
  140. procedure ShowMouse; assembler;
  141.  asm
  142.   mov ax,1
  143.   int 33h
  144. end; {ShowMouse}
  145. procedure HideMouse; assembler;
  146.  asm
  147.   mov ax,2
  148.   int 33h
  149. end; {HideMouse}
  150. procedure ChangeMousePointer (x,y:integer; zeiger:word); assembler;
  151. asm
  152.  mov ax,9
  153.  mov bx,x
  154.  mov bx,y
  155.  mov dx,zeiger
  156.  int 33h
  157. end; {ChangeMousePointer}
  158.  
  159. begin
  160.  gd:=VGA; gm := VGAHi;
  161.  initgraph(gd,gm,'c:\bp\bgi');
  162.   setfillstyle(solidfill,white);
  163.   bar (200,200,400,400);
  164.  cursor[1]:=screenmask; cursor[2]:=cursormask;
  165.  SetBKColor(black);
  166.  ShowMouse;
  167.  ChangeMousePointer(8,8,ofs(cursor));
  168.   readln;
  169.   HideMouse;
  170.   closegraph;
  171. end.
  172.