home *** CD-ROM | disk | FTP | other *** search
- {$a+}
- {$U15}
- {$P-}
- PROGRAM MultiPaint;
-
- {$I c:gemsubs.pas}
- {$I c:auxsubs.pas}
- {$I c:mpaint.i}
-
- mousestate = 79;
- leftbutton = 1;
- rightbutton = 2;
- buttons = 3;
- rightshift = 1;
- leftshift = 2;
- shiftkeys = 3;
- control = 4;
- alternate = 8;
- ShiftAlt = 11;
- ShiftAltCntrl = 14;
- opaque_mode = 1;
- transparent_mode = 2;
- LoadPic = 1;
- SavePic = 2;
- rgbsize = 16;
- Undo = $6100;
- Help = $6200;
- Escape = $011B;
- Tab = $0F09;
- Backspace = $0E08;
- F1 = $3B00;
- F2 = $3C00;
- PicBeg = 1;
- PicEnd = 32256; { integer array }
-
- TYPE
- modetype = draw .. text;
- drawmodetype = 1 .. 2;
- MFDBtype = PACKED ARRAY [ 1 .. 76 ] OF byte;
- picType = PACKED ARRAY [ PicBeg .. PicEnd ] OF byte ;
- RGBtype = PACKED ARRAY [ 0 .. 15 ] OF
- PACKED ARRAY [ 1 .. 3 ] OF integer;
- SliderType = RECORD
- x_inc,y_inc,
- x_size,y_size,
- x_limit,y_limit,
- x_offset,y_offset,
- x_slide,y_slide,h_slide,v_slide : integer
- END;
-
- VAR
- ctrl : Ctrl_Parms;
- int_in : Int_In_Parms;
- int_out : Int_Out_Parms;
- pts_in : Pts_In_Parms;
- pts_out : Pts_Out_Parms;
- addr_in : Addr_In_Parms;
- addr_out : Addr_Out_Parms;
-
- title,info : Window_Title;
- msg : Message_Buffer;
- RGB : RGBtype;
- pic : picType;
- deskcolors,sketchcolors : Palette;
- path : Path_Name;
- c_name : C_String;
- p_name : Str255;
- resource : String[9];
- drawmode : drawmodetype;
- mode : modetype;
- dialog1_ptr,dialog2_ptr : Dialog_Ptr;
- desk_name : Str255;
- mag,wind : SliderType;
- MFDB : MFDBtype;
- picture,pic_start,screen,saturation,coverage,
- oldmouse,newmouse,MFDBptr : long_integer;
- x,y,w,h,
- gzz_x,gzz_y,gzz_w,gzz_h,
- bit_w,bit_h,xmax,ymax,bottomedge,rightedge,
- window,
- bitplanes,byteplanes,nextplane,rowsize,bitsize,aspect,
- paintstyle,XBIOScolor,rez,blitmode,
- dummy,event,
- keystate,key,mx,my,
- Fx,Ox,FOwidth1,FOwidth2,FOxoffset,FOyoffset,
- origx,origy,
- brushwidth,brusheight,textsize,
- radius,palettesize,linestyle,
- inkwellcolor,inkwellspot,inkwell_width,inkwell_height,
- menubar,patternspot,
- ap_id,menu_id : integer;
-
- FUNCTION Addr_Palette( VAR Pal_array : Palette ) : long_integer;
- FUNCTION Addr( VAR Pal_array : Palette ) : long_integer;
- EXTERNAL;
- BEGIN
- Addr_Palette := Addr( Pal_array )
- END;
-
- PROCEDURE Blit( MFDBptr : long_integer );
- C;
-
- FUNCTION InitVec( ymin : integer; oldvec : long_integer ) : long_integer;
- C;
-
- FUNCTION DumVec : long_integer;
- C;
-
- FUNCTION Drive : integer;
- gemdos( $19 );
-
- FUNCTION F_Create( VAR string : C_String;
- attributes : integer ) : integer;
- gemdos( $3C );
-
- FUNCTION F_Close( handle : integer ) : integer;
- gemdos( $3E );
-
- FUNCTION F_Read( handle : integer; count : long_integer;
- picture : long_integer ) : long_integer;
- gemdos( $3F );
-
- FUNCTION F_Write( handle : integer; count : long_integer;
- picture : long_integer ) : long_integer;
- gemdos( $40 );
-
- FUNCTION F_Seek( offset : long_integer;
- handle,mode : integer ) : long_integer;
- gemdos( $42 );
-
- PROCEDURE GetDir( VAR path : C_String; drive : integer );
- gemdos( $47 );
-
- FUNCTION Physbase : long_integer;
- XBIOS( 2 );
-
- FUNCTION Logbase : long_integer;
- XBIOS( 3 );
-
- FUNCTION getrez : integer;
- XBIOS( 4 );
-
- PROCEDURE SetScreen( log,phys : long_integer; rez : integer );
- XBIOS( 5 );
-
- PROCEDURE SetPalette( pal_ptr : long_integer );
- XBIOS( 6 );
-
- FUNCTION SetGetColor( coloreg,color : integer ) : integer;
- XBIOS( 7 );
-
- FUNCTION random : long_integer;
- XBIOS( 17 );
-
- PROCEDURE MouseVector( newvector : long_integer;
- VAR oldvector : long_integer );
- TYPE
- Ctrl_Parms = RECORD
- c6,c5,c4,c3,c2,c1,c0 : integer;
- newvec : long_integer;
- oldvec : long_integer
- END;
- VAR
- ctrl : Ctrl_Parms;
-
- PROCEDURE VDI_Call( cmd,sub_cmd,nints,npts : integer;
- VAR ctrl : Ctrl_Parms;
- VAR int_in : Int_In_Parms;
- VAR int_out : Int_Out_Parms;
- VAR pts_in : Pts_In_Parms;
- VAR pts_out : Pts_Out_Parms;
- translate : boolean );
- EXTERNAL ;
- BEGIN
- ctrl.newvec := newvector;
- VDI_Call( 126,0,0,0,ctrl,int_in,int_out,pts_in,pts_out,FALSE );
- oldvector := ctrl.oldvec
- END;
-
- FUNCTION Pixel( xpos,ypos : integer ) : integer;
- BEGIN
- pts_in[0] := xpos;
- pts_in[1] := ypos;
- VDI_Call( 105,0,0,2,ctrl,int_in,int_out,pts_in,pts_out,FALSE );
- Pixel := int_out[0]
- END;
-
- PROCEDURE Line_Width( size : integer );
- BEGIN
- pts_in[0] := size;
- pts_in[1] := 0;
- VDI_Call( 16,0,0,2,ctrl,int_in,int_out,pts_in,pts_out,FALSE )
- END;
-
- FUNCTION GemToXbios( reg : integer ) : integer;
- BEGIN
- CASE reg OF
- 1:
- CASE rez OF
- 0: GemToXbios := 15;
- 1: GemToXbios := 3;
- 2: GemToXbios := reg
- END;
- 2,3,8,9,10,11:
- GemToXbios := reg-1;
- 7,15: GemToXbios := reg-2;
- 6,14: GemToXbios := reg-3;
- 5,13: GemToXbios := reg+1;
- OTHERWISE:
- GemToXbios := reg
- END
- END;
-
- FUNCTION XbiosToGem( reg : integer ) : integer;
- BEGIN
- CASE reg OF
- 15: XbiosToGem := 1;
- 1,2,7,8,9,10:
- XbiosToGem := reg+1;
- 5,13: XbiosToGem := reg+2;
- 3,11:
- IF rez = 1 THEN
- XbiosToGem := 1
- ELSE
- XbiosToGem := reg+3;
- 6,14: XbiosToGem := reg-1;
- OTHERWISE:
- XbiosToGem := reg
- END
- END;
-
- PROCEDURE StoreColors;
- CONST
- Red = 1792; Green = 112; Blue = 7;
- VAR
- i,col : integer;
- BEGIN
- FOR i := 0 TO 15 DO
- BEGIN
- col := SetGetColor( GemToXbios( i ),-1 );
- RGB[i][1] := ( col & Red ) DIV 256;
- RGB[i][2] := ( col & Green ) DIV 16;
- RGB[i][3] := col & Blue
- END
- END;
-
- PROCEDURE Delay( duration : long_integer );
- BEGIN
- dummy := Get_Event( E_Timer,
- 0,0,0,duration,FALSE,0,0,0,0,FALSE,0,0,0,0,
- msg,dummy,dummy,dummy,dummy,dummy,dummy )
- END;
-
- PROCEDURE LoadError;
- BEGIN
- dummy :=
- Do_Alert('[3][ | |Load Error!| | ][ Understood ]',1 )
- END;
-
- PROCEDURE SaveError;
- BEGIN
- dummy :=
- Do_Alert('[3][ | |Save Error!| | ][ Understood ]',1 )
- END;
-
- PROCEDURE GetColors( VAR col : Palette );
- VAR
- i : integer;
- BEGIN
- FOR i := 0 TO 15 DO
- col[i] := SetGetColor( i,-1 )
- END;
-
- PROCEDURE SavePalette;
- BEGIN
- GetColors( sketchcolors );
- StoreColors
- END;
-
- PROCEDURE ClipWindow( VAR xpos,ypos,width,height : integer );
- BEGIN
- Work_Rect( window,xpos,ypos,width,height );
- gzz_x := xpos;
- gzz_y := ypos+inkwell_height+3;
- gzz_w := width;
- gzz_h := height-inkwell_height-3;
- rightedge := gzz_x+gzz_w-1;
- bottomedge := gzz_y+gzz_h-1;
- Fx := rightedge-FOwidth2+1;
- Ox := rightedge-FOwidth1+1;
- inkwellspot := xpos+( inkwellcolor*inkwell_width );
- WITH wind DO
- BEGIN
- x_size := SHORT_TRUNC(( gzz_w / xmax ) * 1000 );
- y_size := SHORT_TRUNC(( gzz_h / ymax ) * 1000 );
- x_limit := ( xmax-gzz_w )+1;
- y_limit := ( ymax-gzz_h )+1;
- x_slide := SHORT_TRUNC( 1000 / x_limit ) * x_inc;
- y_slide := SHORT_TRUNC( 1000 / y_limit ) * y_inc
- END;
- Set_Clip( gzz_x,gzz_y,gzz_w,gzz_h )
- END;
-
- FUNCTION Click( mask : integer ) : boolean;
- BEGIN
- AES_Call( mousestate,int_in,int_out,addr_in,addr_out );
- Click := int_out[3] & mask <> 0
- END;
-
- FUNCTION ButtonDown( VAR newx,newy : integer ) : boolean;
- BEGIN
- event := Get_Event( E_Message | E_Button | E_Timer,
- 1,1,1,0,FALSE,0,0,0,0,FALSE,0,0,0,0,
- msg,dummy,dummy,dummy,newx,newy,dummy );
- ButtonDown := event & E_Button <> 0
- END;
-
- PROCEDURE Limit( VAR position : integer; min,max : integer );
- BEGIN
- IF position < min THEN position := min;
- IF position > max THEN position := max
- END;
-
- PROCEDURE RubberBox( keystate,mx,my,xmin,ymin,xmax,ymax : integer;
- VAR width,height : integer );
- VAR
- newx,newy : integer;
- BEGIN
- Hide_Mouse;
- Draw_Mode( 3 );
- Line_Color( 1 );
- Line_Style( 1 );
- IF ( mode = box ) OR ( mode = block ) THEN Line_Width( 1 );
- WHILE ButtonDown( newx,newy ) DO
- BEGIN
- Limit( newx,xmin,xmax );
- Limit( newy,ymin,ymax );
- width := ABS( newx-mx );
- IF keystate & shiftkeys <> 0 THEN
- height := width DIV aspect
- ELSE
- height := ABS( newy-my );
- Frame_Rect( mx,my,width,height );
- Delay( 25 );
- Frame_Rect( mx,my,width,height )
- END
- END;
-
- PROCEDURE ModeInfo;
- BEGIN
- CASE mode OF
- draw:
- info := ' DRAW';
- magnify:
- info := ' MAGNIFY';
- circle:
- info := ' CIRCLE';
- disc:
- info := ' DISC';
- frame:
- info := ' FRAME';
- box:
- info := ' BOX';
- airbrush:
- info := ' AIRBRUSH';
- lines:
- info := ' LINE';
- block:
- info := ' COPY';
- pal:
- info := ' PALETTE';
- fill:
- info := ' FILL';
- text:
- info := ' TEXT'
- END
- END;
-
- PROCEDURE ChangeInfo;
- BEGIN
- info := '';
- Set_Winfo( window,info );
- ModeInfo;
- Set_Winfo( window,info )
- END;
-
- PROCEDURE Attributes;
- BEGIN
- Paint_Style( paintstyle );
- Paint_Color( XBIOScolor );
- Line_Color( XBIOScolor );
- Line_Style( linestyle );
- Line_Width( brushwidth );
- Draw_Mode( drawmode );
- Text_Color( XBIOScolor );
- Text_Style( Normal );
- Text_Height( textsize )
- END;
-
- PROCEDURE CopyRaster( source,destination : long_integer;
- src_xorigin,src_yorigin,dest_xorigin,dest_yorigin,
- dest_x,dest_y,width,height,mode : integer );
-
- PROCEDURE DoBlit( src_ptr,dest_ptr : long_integer;
- src_x,src_y,s_nextplane,d_nextplane,copymode :integer);
- BEGIN
- WPOKE( MFDBptr,width );
- WPOKE( MFDBptr+2,height );
- WPOKE( MFDBptr+4,bitplanes );
- POKE( MFDBptr+10,copymode );
- POKE( MFDBptr+11,copymode );
- POKE( MFDBptr+12,copymode );
- POKE( MFDBptr+13,copymode );
- WPOKE( MFDBptr+14,src_x );
- WPOKE( MFDBptr+16,src_y );
- LPOKE( MFDBptr+18,src_ptr );
- WPOKE( MFDBptr+26,s_nextplane );
- WPOKE( MFDBptr+28,dest_x );
- WPOKE( MFDBptr+30,dest_y );
- LPOKE( MFDBptr+32,dest_ptr );
- WPOKE( MFDBptr+40,d_nextplane );
- Blit( MFDBptr )
- END;
-
- BEGIN
- Hide_Mouse;
- IF mode = 7 THEN
- BEGIN
- { 1. Clear dest
- 2. Combine source and dest into one plane
- 3. Unroll dest into multiple planes
- 4. Source AND ( NOT dest ) }
- DoBlit( source,destination,src_xorigin,src_yorigin,
- nextplane,nextplane,0 );
- DoBlit( source,destination,src_xorigin,src_yorigin,nextplane,0,7 );
- DoBlit( destination,destination,dest_x,dest_y,0,nextplane,7 );
- DoBlit( source,destination,dest_xorigin,dest_yorigin,
- nextplane,nextplane,2 )
- END;
- DoBlit( source,destination,src_xorigin,src_yorigin,
- nextplane,nextplane,mode );
- Show_Mouse
- END;
-
- PROCEDURE Blit_to_Screen;
- BEGIN
- screen := Physbase;
- CASE mode OF
- magnify,pal: ;
- OTHERWISE:
- CopyRaster( picture,screen,wind.x_offset,wind.y_offset,0,0,
- gzz_x,gzz_y,gzz_w,gzz_h,3 )
- END
- END;
-
- PROCEDURE Blit_to_Memory;
- BEGIN
- screen := Physbase;
- CASE mode OF
- magnify: ;
- pal:
- SavePalette;
- OTHERWISE:
- CopyRaster( screen,picture,gzz_x,gzz_y,0,0,
- wind.x_offset,wind.y_offset,gzz_w,gzz_h,3 )
- END
- END;
-
- PROCEDURE ClearPic;
- VAR
- i : integer;
- BEGIN
- FOR i := PicBeg TO PicEnd DO
- pic[i] := 0
- END;
-
- PROCEDURE SetVariables;
- VAR
- i : integer;
-
- FUNCTION Addr_Pic( VAR Screen_pic : picType ) : long_integer;
- FUNCTION Addr( VAR Screen_pic : picType ) : long_integer;
- EXTERNAL;
- BEGIN
- Addr_Pic := Addr( Screen_pic )
- END;
-
- FUNCTION Addr_MFDB( VAR MFDB : MFDBtype ) : long_integer;
- FUNCTION Addr( VAR MFDB : MFDBtype ) : long_integer;
- EXTERNAL;
- BEGIN
- Addr_MFDB := Addr( MFDB )
- END;
-
- BEGIN
- inkwellcolor := 1;
- XBIOScolor := XbiosToGem( inkwellcolor );
- paintstyle := 1;
- linestyle := 1;
- brushwidth := 1;
- textsize := 3;
- bitsize := 5;
- patternspot := ( inkwell_width*palettesize )+1;
- drawmode := transparent_mode;
- blitmode := 7;
- mode := draw;
- saturation := 35;
- coverage := 15;
- pic_start := Addr_Pic( pic );
- MFDBptr := Addr_MFDB( MFDB );
- picture := (( pic_start DIV 256 ) * 256 ) + 256;
- GetDir( c_name,Drive );
- C_TO_PSTR( c_name,p_name );
- path := CONCAT( CHR( $41+Drive ),':',p_name,'\*.*' );
- p_name := '';
- WPOKE( MFDBptr+6,1 );
- WPOKE( MFDBptr+8,0 );
- WPOKE( MFDBptr+22,byteplanes );
- WPOKE( MFDBptr+24,rowsize );
- WPOKE( MFDBptr+36,byteplanes );
- WPOKE( MFDBptr+38,rowsize );
- LPOKE( MFDBptr+42,0 );
- WPOKE( MFDBptr+46,0 );
- WPOKE( MFDBptr+48,0 );
- WPOKE( MFDBptr+50,0 );
- FOR i := 52 TO 75 DO
- POKE( MFDBptr+i,0 );
- WITH wind DO
- BEGIN
- h_slide := 1;
- v_slide := 1;
- x_offset := 0;
- y_offset := 0;
- x_inc := 8;
- y_inc := 10;
- x_size := -1;
- y_size := -1
- END;
- mag := wind;
- mag.x_inc := 1;
- mag.y_inc := 1
- END;
-
- PROCEDURE GetResolution;
- BEGIN
- rez := getrez;
- CASE rez OF
- 0: { low-res }
- BEGIN
- xmax := 319;
- ymax := 199;
- menubar := 12;
- bitplanes := 4;
- nextplane := 2;
- aspect := 1;
- rowsize := 160;
- palettesize := 16;
- FOwidth1 := 19;
- FOwidth2 := 38;
- FOxoffset := 1;
- FOyoffset := 17;
- inkwell_width := 12;
- inkwell_height := 20
- END;
-
- 1: { medium-res }
- BEGIN
- xmax := 639;
- ymax := 199;
- menubar := 12;
- bitplanes := 2;
- nextplane := 2;
- aspect := 2;
- rowsize := 160;
- palettesize := 4;
- FOwidth1 := 34;
- FOwidth2 := 68;
- FOxoffset := 8;
- FOyoffset := 17;
- inkwell_width := 64;
- inkwell_height := 20
- END;
-
- 2:
- BEGIN { high-res }
- xmax := 639;
- ymax := 399;
- menubar := 20;
- bitplanes := 1;
- nextplane := 0;
- aspect := 1;
- rowsize := 80;
- palettesize := 2;
- FOwidth1 := 34;
- FOwidth2 := 68;
- FOxoffset := 8;
- FOyoffset := 32;
- inkwell_width := 128;
- inkwell_height := 40
- END
- END;
- byteplanes := bitplanes * 2
- END;
-
- PROCEDURE Initialize;
- BEGIN
- GetResolution;
- SetVariables;
- GetColors( deskcolors );
- SavePalette;
- ClearPic;
- title := ' MultiPaint ';
- IO_Check( FALSE );
- Attributes
- END;
-
- PROCEDURE DrawPatternBox;
- BEGIN
- Paint_Outline( TRUE );
- Paint_Color( 1 );
- Paint_Style( paintstyle );
- Draw_Mode( 1 );
- Paint_Rect( x+patternspot,y+1,w-patternspot-FOwidth2-1,inkwell_height )
- END;
-
- PROCEDURE ClearWindow;
- BEGIN
- Hide_Mouse;
- Paint_Color( 0 );
- Paint_Style( 1 );
- Paint_Rect( x,y,w,h );
- Attributes;
- Show_Mouse
- END;
-
- PROCEDURE DoPaint( xpos,ypos : integer );
- BEGIN
- Hide_Mouse;
- int_in[0] := -1;
- pts_in[0] := xpos;
- pts_in[1] := ypos;
- VDI_Call( 103,0,1,2,ctrl,int_in,int_out,pts_in,pts_out,FALSE );
- Show_Mouse
- END;
-
- PROCEDURE FatBits;
- VAR
- i,j,row_pos,row,fatsize : integer;
- log : long_integer;
- BEGIN
- Paint_Outline( TRUE );
- Paint_Style( 1 );
- Line_Color( 1 );
- Line_Style( 1 );
- Line_Width( 1 );
- log := Logbase;
- fatsize := bitsize-1;
- Hide_Mouse;
- info := ' Wait ...';
- Set_Winfo( window,info );
- Frame_Rect( gzz_x-1,gzz_y-1,
- ( bitsize*( bit_w+1 ))+1,( bitsize*( bit_h+1 ))+1 );
- WITH mag DO
- BEGIN
- FOR j := 0 TO bit_h DO
- BEGIN
- row := y_offset+j;
- row_pos := gzz_y+( j*bitsize );
- FOR i := 0 TO bit_w DO
- BEGIN
- SetScreen( picture,-1,-1 );
- IF Pixel( x_offset+i,row ) <> 0 THEN
- BEGIN
- Paint_Color( int_out[1] );
- SetScreen( log,-1,-1 );
- Paint_Rect( gzz_x+( i*bitsize ),row_pos,fatsize,fatsize )
- END
- END
- END
- END;
- SetScreen( log,-1,-1 );
- ChangeInfo;
- Show_Mouse;
- Attributes
- END;
-
- PROCEDURE ColorPanel;
- CONST
- RGBcenter = 12;
- VAR
- RGBchar : ARRAY [ 1 .. 3 ] OF char;
- i,j,intensity,xpos,ypos,left,right : integer;
- BEGIN
- Hide_Mouse;
- Text_Color( 1 );
- Line_Color( 1 );
- Paint_Color( 1 );
- Line_Style( 1 );
- Line_Width( 1 );
- Paint_Style( 1 );
- Text_Style( Normal );
- Text_Height( 8 );
- Paint_Outline( TRUE );
- RGBchar[1] := 'R';
- RGBchar[2] := 'G';
- RGBchar[3] := 'B';
- left := gzz_x+( rgbsize DIV 4 );
- right := left+( rgbsize * 9 );
- FOR j := 1 TO 3 DO
- BEGIN
- ypos := gzz_y+(( j-1 )*rgbsize );
- intensity := RGB[XBIOScolor][j]+1;
- FOR i := 0 TO 9 DO
- BEGIN
- xpos := gzz_x+( i*rgbsize );
- IF intensity = i THEN
- Paint_Rect( xpos,ypos,rgbsize,rgbsize )
- ELSE
- Frame_Rect( xpos,ypos,rgbsize,rgbsize )
- END;
- ypos := ypos+RGBcenter;
- Draw_String( left,ypos,RGBchar[j] );
- Draw_String( right,ypos,RGBchar[j] );
- END;
- Attributes;
- Show_Mouse
- END;
-
- PROCEDURE DrawScreen;
- VAR
- i,ypos : integer;
- BEGIN
- ClearWindow;
- Paint_Style( 1 );
- Line_Color( 1 );
- Line_Style( 1 );
- Line_Width( 1 );
- Text_Color( 1 );
- Text_Style( Outlined );
- IF rez = 2 THEN
- Text_Height( 26 )
- ELSE
- Text_Height( 12 );
- FOR i := 1 TO palettesize-1 DO
- BEGIN
- Paint_Color( XbiosToGem( i ));
- Paint_Rect( x+( i*inkwell_width ),y+1,inkwell_width,inkwell_height )
- END;
- Frame_Rect( x,y+1,inkwell_width,inkwell_height );
- Frame_Rect( inkwellspot,y,inkwell_width,inkwell_height+2 );
- ypos := gzz_y-1;
- Line( gzz_x,ypos,gzz_x+gzz_w,ypos );
- Draw_Mode( 2 );
- Frame_Rect( Fx,y+1,FOwidth1-1,inkwell_height );
- Frame_Rect( Ox,y+1,FOwidth1-1,inkwell_height );
- Draw_String( Fx+FOxoffset,y+FOyoffset,'F' );
- Draw_String( Ox+FOxoffset,y+FOyoffset,'O' );
- DrawPatternBox;
- Attributes;
- CASE mode OF
- magnify: FatBits;
- pal: ColorPanel;
- OTHERWISE: Blit_to_Screen
- END
- END;
-
- PROCEDURE Redraw;
- BEGIN
- Begin_Update;
- Hide_Mouse;
- Set_Clip( x,y,w,h );
- DrawScreen;
- Set_Clip( gzz_x,gzz_y,gzz_w,gzz_h );
- Show_Mouse;
- End_Update
- END;
-
- FUNCTION Slider( slide,limit,WF_Flag : integer ) : integer;
- BEGIN
- Slider := SHORT_TRUNC(( slide / 1000 ) * limit );
- Wind_Set( window,WF_Flag,slide,0,0,0 )
- END;
-
- PROCEDURE ScrollBars;
-
- PROCEDURE SetSliders( h_slide,v_slide,x_size,y_size : integer );
- BEGIN
- Wind_Set( window,WF_HSlide,h_slide,0,0,0 );
- Wind_Set( window,WF_VSlide,v_slide,0,0,0 );
- Wind_Set( window,WF_HSlSize,x_size,0,0,0 );
- Wind_Set( window,WF_VSlSize,y_size,0,0,0 )
- END;
-
- BEGIN
- CASE mode OF
- magnify:
- WITH mag DO
- BEGIN
- bit_w := ( gzz_w DIV bitsize )-1;
- bit_h := ( gzz_h DIV bitsize )-1;
- x_limit := xmax-bit_w;
- y_limit := ymax-bit_h;
- x_slide := SHORT_ROUND( 1000 / ( x_limit+1 ));
- y_slide := SHORT_ROUND( 1000 / ( y_limit+1 ));
- x_offset := Slider( h_slide,x_limit,WF_HSlide );
- y_offset := Slider( v_slide,y_limit,WF_VSlide );
- SetSliders( h_slide,v_slide,x_size,y_size )
- END;
- pal: ;
- OTHERWISE:
- WITH wind DO
- SetSliders( h_slide,v_slide,x_size,y_size )
- END
- END;
-
- FUNCTION EventMulti : integer;
- BEGIN
- EventMulti := Get_Event( E_Message | E_Keyboard | E_Button |
- E_Timer | E_MRect_1,
- 1,1,1,0,FALSE,x,y,w,h,TRUE,0,0,0,0,
- msg,key,dummy,dummy,mx,my,keystate )
- END;
-
- PROCEDURE BlockCopy( keystate,xpos,ypos : integer );
- VAR
- key,origx,origy,newx,newy,width,height,xorigin,yorigin : integer;
- Move : boolean;
-
- PROCEDURE TrapBlit( VAR xpos,ypos : integer );
- BEGIN
- Limit( xpos,gzz_x,rightedge-width+1 );
- Limit( ypos,gzz_y,bottomedge-height+1 );
- END;
-
- PROCEDURE BlitToOrigin;
- ^DGIN
- CopyRaster( picture,screen,
- xorigin,yorigin,0,0,origx,origy,width,height,6 )
- END;
-
- PROCEDURE BlitToMouse( mode : integer );
- BEGIN
- CopyRaster( picture,screen,xorigin,yorigin,
- wind.x_offset+newx-gzz_x,wind.y_offset+newy-gzz_y,
- newx,newy,width,height,mode )
- END;
-
- BEGIN
- Blit_to_Memory;
- Limit( xpimit( xpimit( xpimit( xpimit( xp );
- LPOKE( MFDBptr+42,0 );
- WPOKE( MFDBptr+46,0 );
- WPOKE( MFDBptr+48,0 );
- WPOKE( MFDBptr+50,0 );
- FOR i := 52 TO 75 DO
- POKE( MFDBptr+i,0 );
- WITH wind DO
- BEGIN
- h_slide := 1;
- v_slide := 1;
- x_offset := 0;
- y_offset := 0;
- x_inc := 8;
- y_inc := 10;
- x_size := -1;
- y_size := -1
- END;
- mag := wind;
- mag.x_inc := 1;
- mag.y_inc := 1
- END;
-
- PROCEDURE GetResolution;
- BEGIN
- rez := getrez;
- CASE rez OF
- 0: { low-res }
- BEGIN
- xmax := 319;
- ymax := 199;
- menubar := 12;
- bitplanes := 4;
- nextplane := 2;
- aspect := 1;
- rowsize := 160;
- palettesize := 16;
- FOwidth1 := 19;
- FOwidth2 := 38;
- FOxoffset := 1;
- FOyoffset := 17;
- inkwell_width := 12;
- inkwell_height := 20
- END;
-
- 1: { medium-res }
- BEGIN
- xmax := 639;
- ymax := 199;
- menubar := 12;
- bitplanes := 2;
- nextplane := 2;
- aspect := 2;
- rowsize := 160;
- palettesize := 4;
- FOwidth1 := 34;
- FOwidth2 := 68;
- FOxoffset := 8;
- FOyoffset := 17;
- inkwell_width := 64;
- inkwell_height := 20
- END;
-
- 2:
- BEGIN { high-res }
- xmax := 639;
- ymax := 399;
- menubar := 20;
- bitplanes := 1;
- nextplane := 0;
- aspect := 1;
- rowsize := 80;
- palettesize := 2;
- FOwidth1 := 34;
- FOwidth2 := 68;
- FOxoffset := 8;
- FOyoffset := 32;
- inkwell_width := 128;
- inkwell_height := 40
- END
- END;
- byteplanes := bitplanes * 2
- END;
-
- PROCEDURE Initialize;
- BEGIN
- GetResolution;
- SetVariables;
- GetColors( deskcolors );
- SavePalette;
- ClearPic;
- title := ' MultiPaint ';
- IO_Check( FALSE );
- Attributes
- END;
-
- Pide,title,0,0,0,0 );
- Open_window( window,0,0,0,0 );
- Border_Rect( window,x,y,w,h );
- ClipWindow( x,y,w,h );
- ScrollBars;
- ChangeInfo;
- END
- END;
-
- PROCEDURE SketchOff;
- VAR
- current_window : integer;
- dummy : long_integer;
- BEGIN
- Blit_to_Memory;
- IF keystate & alternate = 0 THEN
- SetPalette( Addr_Palette( deskcolors ));
- Close_Window( window );
- Delete_Window( window );
- window := No_Window;
- MouseVector( oldmouse,dummy )
- END;
-
- PROCEDURE Perimeter( keystate : integer );
- BEGIN
- IF keystate & control <> 0 THEN
- Paint_OutLine( TRUE )
- ELSE
- Paint_Outline( FALSE )
- END;
-
- PROCEDURE DoMagnify( mx,my : integer );
- VAR
- xpix,ypix : integer;
- log : long_integer;
- BEGIN
- xpix := ( mx-gzz_x ) DIV bitsize;
- ypix := ( my-gzz_y ) DIV bitsize;
- IF ( xpix <= bit_w ) AND ( ypix <= bit_h ) THEN
- BEGIN
- Paint_OutLine( TRUE );
- Paint_Style( 1 );
- Line_Style( 1 );
- Line_Width( 1 );
- Hide_Mouse;
- Paint_Rect( gzz_x+( xpix * bitsize ),gzz_y+( ypix * bitsize ),
- bitsize-1,bitsize-1 );
- Show_Mouse;
- log := Logbase;
- SetScreen( picture,-1,-1 );
- Set_Clip( 0,0,xmax+1,ymax+1 );
- Plot( mag.x_offset+xpix,mag.y_offset+ypix );
- Set_Clip( gzz_x,gzz_y,gzz_w,gzz_h );
- SetScreen( log,-1,-1 );
- Attributes
- END
- END;
-
- PROCEDURE DoAirbrush;
- VAR
- newx,newy : integer;
-
- PROCEDURE FindSpot;
- BEGIN
- newx := newx+( SHR( random,5 ) & coverage );
- Delay( saturation );
- newy := newy+( SHR( random,5 ) & coverage )
- END;
-
- BEGIN
- Hide_Mouse;
- Line_Width( 1 );
- Paint_Outline( FALSE );
- IF brushwidth > 1 THEN
- WHILE ButtonDown( newx,newy ) DO
- BEGIN
- FindSpot;
- Paint_Rect( newx,newy,brushwidth,brusheight )
- END
- ELSE
- WHILE ButtonDown( newx,newy ) DO
- BEGIN
- FindSpot;
- Plot( newx,newy )
- END;
- Attributes;
- Show_Mouse
- END;
-
- PROCEDURE DoLine( keystate,mx,my : integer );
- VAR
- newx,newy : integer;
-
- PROCEDURE OriginAt( xpos,ypos : integer );
- BEGIN
- origx := xpos;
- origy := ypos
- END;
-
- BEGIN
- IF keystate & control <> 0 THEN { establish starting point }
- BEGIN
- Set_Mouse( M_Thin_Cross );
- WHILE Click( leftbutton ) DO ;
- OriginAt( int_out[1],int_out[2] );
- Set_Mouse( M_Arrow )
- END
- ELSE
- BEGIN
- Hide_Mouse;
- IF keystate & shiftkeys <> 0 THEN { Rays }
- Line( origx,origy,mx,my )
- ELSE
- BEGIN { Lines }
- Draw_Mode( 3 );
- IF keystate & alternate = 0 THEN { no Kline }
- OriginAt( mx,my );
- WHILE ButtonDown( newx,newy ) DO
- BEGIN
- Line( origx,origy,newx,newy );
- Delay( 25 );
- Line( origx,origy,newx,newy )
- END;
- Draw_Mode( drawmode );
- Line( origx,origy,newx,newy );
- OriginAt( newx,newy )
- END;
- Show_Mouse
- END
- END;
-
- PROCEDURE DoBox( keystate,mx,my : integer );
- VAR
- bwidth,bheight : integer;
- BEGIN
- RubberBox( keystate,mx,my,0,0,xmax,ymax,bwidth,bheight );
- Attributes;
- IF mode = box THEN
- BEGIN
- Perimeter( keystate );
- IF keystate & alternate <> 0 THEN
- Paint_Round_Rect( mx,my,bwidth,bheight )
- ELSE
- Paint_Rect( mx,my,bwidth,bheight )
- END
- ELSE
- IF keystate & alternate <> 0 THEN
- Frame_Round_Rect( mx,my,bwidth,bheight )
- ELSE
- Frame_Rect( mx,my,bwidth,bheight );
- Show_Mouse
- END;
-
- PROCEDURE DoCircle( keystate,mx,my : integer );
- VAR
- xradius,yradius,newx,newy : integer;
- BEGIN
- Draw_Mode( 3 );
- IF mode = disc THEN Line_Width( 1 );
- Hide_Mouse;
- WHILE ButtonDown( newx,newy ) DO
- BEGIN
- xradius := ABS( newx-mx );
- IF keystate & shiftkeys <> 0 THEN
- yradius := xradius DIV aspect
- ELSE
- yradius := ABS( newy-my );
- Frame_Oval( mx,my,xradius,yradius );
- Frame_Oval( mx,my,xradius,yradius )
- END;
- Attributes;
- IF mode = disc THEN
- BEGIN
- Perimeter( keystate );
- Paint_Oval( mx,my,xradius,yradius )
- END
- ELSE
- Frame_Oval( mx,my,xradius,yradius );
- Show_Mouse
- END;
-
- PROCEDURE DoDraw( keystate,mx,my : integer );
- VAR
- newx,newy : integer;
-
- PROCEDURE Point;
- BEGIN
- Hide_Mouse;
- Plot( mx,my );
- Show_Mouse
- END;
-
- BEGIN
- Paint_OutLine( TRUE );
- Line_Style( 1 );
- Line_Width( 1 );
- IF brushwidth = 1 THEN
- CASE keystate & ShiftAlt OF
- alternate:
- Point;
- leftshift,rightshift:
- BEGIN
- Point;
- WHILE Click( leftbutton ) DO ;
- END;
- OTHERWISE:
- WHILE ButtonDown( newx,newy ) DO
- BEGIN
- Hide_Mouse;
- Line( mx,my,newx,newy );
- Show_Mouse;
- mx := newx;
- my := newy
- END
- END
- ELSE
- BEGIN
- Hide_Mouse;
- Paint_OutLine( FALSE );
- CASE keystate & ShiftAlt OF
- alternate:
- Paint_Rect( mx,my,brushwidth,brusheight );
- leftshift,rightshift:
- BEGIN
- Paint_Rect( mx,my,brushwidth,brusheight );
- WHILE Click( leftbutton ) DO ;
- END;
- OTHERWISE:
- WHILE ButtonDown( newx,newy ) DO
- Paint_Rect( newx,newy,brushwidth,brusheight )
- END;
- Show_Mouse
- END;
- Attributes
- END;
-
- PROCEDURE SetColor( mx : integer );
- VAR
- frame_size,inkwell_y : integer;
- BEGIN
- Hide_Mouse;
- Set_Clip( x,y,w,h );
- frame_size := inkwell_height+2;
- inkwell_y := y+1;
- Paint_Style( 1 );
- Line_Color( 1 );
- Line_Style( 1 );
- Line_Width( 1 );
- Paint_Outline( FALSE );
- Paint_Color( 0 );
- Paint_Rect( inkwellspot,y,inkwell_width,frame_size );
- Paint_Color ( XBIOScolor );
- IF XBIOScolor = 0 THEN
- Frame_Rect( inkwellspot,inkwell_y,inkwell_width,inkwell_height )
- ELSE
- Paint_Rect( inkwellspot,inkwell_y,inkwell_width,inkwell_height );
- inkwellcolor := ( mx-x ) DIV inkwell_width;
- XBIOScolor := XbiosToGem( inkwellcolor );
- inkwellspot := x+( inkwellcolor*inkwell_width );
- Frame_Rect( inkwellspot,y,inkwell_width,frame_size );
- Show_Mouse;
- Set_Clip( gzz_x,gzz_y,gzz_w,gzz_h );
- Attributes;
- IF mode = pal THEN
- BEGIN
- ClearWindow;
- ColorPanel
- END
- END;
-
- PROCEDURE SetPattern( keystate : integer );
- BEGIN
- CASE keystate OF
- control: paintstyle := 1; { solid }
- leftshift,
- rightshift: paintstyle := 26; { dither patterns }
- alternate: paintstyle := paintstyle-1;
- OTHERWISE: paintstyle := paintstyle+1
- END;
- IF paintstyle > 37 THEN
- paintstyle := 0;
- IF paintstyle < 0 THEN
- paintstyle := 37;
- Hide_Mouse;
- Set_Clip( x,y,w,h );
- DrawPatternBox;
- Attributes;
- Set_Clip( gzz_x,gzz_y,gzz_w,gzz_h );
- Show_Mouse;
- Delay( 100 )
- END;
-
- PROCEDURE SetRGB( mx,my : integer );
- VAR
- i,intensity,gun : integer;
-
- PROCEDURE MoveBox( VAR old_intensity : integer; new_intensity : integer );
- VAR
- xpos,ypos,size : integer;
- BEGIN
- Paint_Color( 0 );
- Paint_Style( 1 );
- Hide_Mouse;
- xpos := gzz_x+rgbsize+1;
- ypos := gzz_y+(( gun-1 ) * rgbsize )+1;
- size := rgbsize-2;
- Paint_Rect( xpos+( old_intensity * rgbsize ),ypos,size,size );
- Paint_Color( 1 );
- Paint_Rect( xpos+( new_intensity * rgbsize ),ypos,size,size );
- Show_Mouse;
- Delay( 50 );
- Attributes;
- old_intensity := new_intensity
- END;
-
- BEGIN
- intensity := ( mx-gzz_x ) DIV rgbsize;
- gun := (( my-gzz_y ) DIV rgbsize ) + 1;
- IF ( gun < 4 ) AND ( intensity < 10 ) THEN
- BEGIN
- CASE intensity OF
- 0:
- IF RGB[XBIOScolor][gun] > 0 THEN
- MoveBox( RGB[XBIOScolor][gun],RGB[XBIOScolor][gun]-1 );
- 9:
- IF RGB[XBIOScolor][gun] < 7 THEN
- MoveBox( RGB[XBIOScolor][gun],RGB[XBIOScolor][gun]+1 );
- 1,2,3,4,5,6,7,8:
- MoveBox( RGB[XBIOScolor][gun],intensity-1 )
- END;
- dummy := SetGetColor( GemToXbios( XBIOScolor ),
- ( RGB[XBIOScolor][1]*256 )+( RGB[XBIOScolor][2]*16 )+
- RGB[XBIOScolor][3] )
- END
- END;
-
- PROCEDURE DoText( keystate,origx,origy : integer );
- VAR
- keystring : Str255;
- stylemask,len : integer;
-
- PROCEDURE DrawText( xpos,ypos : integer );
- BEGIN
- Line( xpos-1,ypos,xpos-1,ypos-textsize );
- Draw_String( xpos,ypos,keystring )
- END;
-
- PROCEDURE Style( keymask,textmask : integer );
- BEGIN
- IF keystate & keymask <> 0 THEN
- stylemask := stylemask | textmask
- END;
-
- BEGIN
- WHILE Click( leftbutton ) DO ;
- Begin_Mouse;
- Hide_Mouse;
- Draw_Mode( 3 );
- Line_Style( 1 );
- Line_Width( 1 );
- stylemask := 0;
- Style( alternate,Thickened );
- Style( control,Slanted );
- Style( leftshift,Outlined );
- Style( rightshift,Underlined );
- Text_Style( stylemask );
- keystring := '';
- DrawText( origx,origy );
- REPEAT
- event := EventMulti;
- IF ( mx <> origx ) OR ( my <> origy ) THEN
- BEGIN
- DrawText( origx,origy );
- DrawText( mx,my );
- origx := mx;
- origy := my
- END
- ELSE
- IF event & E_Keyboard <> 0 THEN
- BEGIN
- DrawText( origx,origy );
- len := LENGTH( keystring );
- IF key = Backspace THEN
- BEGIN
- IF len > 0 THEN
- DELETE( keystring,len,1 )
- END
- ELSE
- IF len < 255 THEN
- keystring := CONCAT( keystring,CHR( key ));
- DrawText( mx,my )
- END
- UNTIL Click( leftbutton );
- WHILE Click( leftbutton ) DO ;
- DrawText( mx,my );
- Draw_Mode( drawmode );
- Draw_String( mx,my,keystring );
- Show_Mouse;
- End_Mouse;
- Attributes
- END;
-
- PROCEDURE Sketch( keystate,mx,my : integer );
- BEGIN
- CASE mode OF
- draw: DoDraw( keystate,mx,my );
- magnify: DoMagnify( mx,my );
- circle,disc: DoCircle( keystate,mx,my );
- frame,box: DoBox( keystate,mx,my );
- airbrush: DoAirbrush;
- lines: DoLine( keystate,mx,my );
- block: BlockCopy( keystate,mx,my );
- fill: DoPaint( mx,my );
- text: DoText( keystate,mx,my );
- pal: SetRGB( mx,my )
- END
- END;
-
- PROCEDURE Disk( operation : integer );
- CONST
- NEO = 2;
- VAR
- H,i,header,colors,offset : integer;
- header_addr,count : long_integer;
- format : String[60];
- TM : char;
- BEGIN
- header := 34;
- colors := 34;
- offset := 2;
- TM := CHR( $BF );
- format := CONCAT('[2][ | | Which Format? | ][ DEGAS',TM,
- ' | NEOchrome',TM,' ]' );
- IF rez = 0 THEN
- IF Do_Alert( format,0 ) = NEO THEN
- BEGIN
- header := 128;
- colors := 36;
- offset := 4
- END;
- IF Get_In_File( path,p_name ) THEN
- BEGIN
- Set_Mouse( M_Bee );
- CASE operation OF
- LoadPic:
- BEGIN
- Reset( Input,p_name );
- IF EOF( Input ) THEN
- LoadError
- ELSE
- BEGIN
- H := Handle( Input );
- count := F_Seek( 0,H,0 );
- count := F_Read( H,colors,pic_start );
- SetPalette( pic_start+offset );
- Delay( 60 );
- SavePalette;
- count := F_Seek( header,H,0 );
- count := F_Read( H,32000,picture );
- Close( Input );
- IF count <> 32000 THEN
- LoadError
- END
- END;
- SavePic:
- BEGIN
- P_TO_CSTR( p_name,c_name );
- H := F_Create( c_name,0 );
- IF H >= 0 THEN { Error? }
- BEGIN
- IF picture-pic_start >= header THEN
- header_addr := pic_start
- ELSE
- header_addr := picture+32000;
- FOR i := 0 TO header-1 DO
- POKE( header_addr+i,0 );
- WPOKE( header_addr,rez );
- MOVE_WORD( Addr_Palette( sketchcolors ),header_addr+offset,16 );
- count := F_Seek( 0,H,2 );
- count := F_Write( H,header,header_addr );
- count := F_Seek( 0,H,2 );
- count := F_Write( H,32000,picture );
- dummy := F_Close( H );
- IF count <> 32000 THEN
- SaveError
- END
- ELSE
- SaveError
- END
- END;
- Set_Mouse( M_Arrow )
- END
- END;
-
- FUNCTION Chosen( dialogptr : Dialog_Ptr; index : integer ) : boolean;
- BEGIN
- Chosen := Obj_State( dialogptr,index ) & 1 <> 0
- END;
-
- PROCEDURE SetOptions;
- VAR
- i : integer;
- BEGIN
- FOR i := narrow TO wide DO
- IF Chosen( dialog2_ptr,i ) THEN
- coverage := i;
- CASE coverage OF
- narrow: coverage := 7;
- medium: coverage := 31;
- wide: coverage := 63
- END;
-
- FOR i := heavy TO light DO
- IF Chosen( dialog2_ptr,i ) THEN
- saturation := i;
- CASE saturation OF
- heavy: saturation := 0;
- moderate: saturation := 35;
- light: saturation := 70
- END;
-
- FOR i := line1 TO line6 DO
- IF Chosen( dialog2_ptr,i ) THEN
- linestyle := i-( line1-1 );
- Line_Style( linestyle );
-
- FOR i := brush1 TO brush6 DO
- IF Chosen( dialog2_ptr,i ) THEN
- BEGIN
- brushwidth := (( i-brush1 )*4 )+1;
- CASE i OF
- brush1: textsize := 3;
- brush2: textsize := 4;
- brush3: textsize := 6;
- brush4: textsize := 12;
- brush5: textsize := 13;
- brush6: textsize := 26
- END
- END;
- brusheight := brushwidth DIV aspect;
- Line_Width( brushwidth );
- bitsize := brushwidth+1;
- Limit( bitsize,6,22 )
- END;
-
- PROCEDURE OptionDialog;
- VAR
- option_button : Tree_Index;
- BEGIN
- Center_Dialog( dialog2_ptr );
- option_button := Do_Dialog( dialog2_ptr,0 );
- Obj_Setstate( dialog2_ptr,ok2,Normal,TRUE );
- End_Dialog( dialog2_ptr );
- SetOptions
- END;
-
- PROCEDURE SketchDialog;
- VAR
- i,clear_picture : integer;
- sketch_button : Tree_Index;
-
- BEGIN
- Begin_Mouse;
- Blit_to_Memory;
- Center_Dialog( dialog1_ptr );
- sketch_button := Do_Dialog( dialog1_ptr,0 );
- LOOP
- clear_picture := 0;
- IF Chosen( dialog1_ptr,load ) THEN
- BEGIN
- Obj_Setstate( dialog1_ptr,load,Normal,TRUE );
- Disk( LoadPic );
- Show_Dialog( dialog1_ptr,0 )
- END
- ELSE
- IF Chosen( dialog1_ptr,save ) THEN
- BEGIN
- Obj_Setstate( dialog1_ptr,save,Normal,TRUE );
- Disk( SavePic );
- Show_Dialog( dialog1_ptr,0 )
- END;
-
- IF Chosen( dialog1_ptr,wipe ) THEN
- BEGIN
- Obj_Setstate( dialog1_ptr,wipe,Normal,TRUE );
- clear_picture := Do_Alert
- ('[3][ | Wipe Picture? | Are You Sure? | ][ Yes | No ]',1 );
- IF clear_picture = 1 THEN
- BEGIN
- ClearWindow;
- ClearPic
- END
- END;
-
- IF Chosen( dialog1_ptr,option ) THEN
- BEGIN
- Obj_Setstate( dialog1_ptr,option,Normal,TRUE );
- OptionDialog;
- Show_Dialog( dialog1_ptr,0 );
- sketch_button := 0
- END;
-
- EXIT IF ( clear_picture = 1 ) OR ( sketch_button = OK1 );
- sketch_button := Redo_Dialog( dialog1_ptr,0 )
- END;
- Obj_Setstate( dialog1_ptr,wipe,Normal,TRUE );
- Obj_Setstate( dialog1_ptr,ok1,Normal,TRUE );
- End_Dialog( dialog1_ptr );
-
- IF Chosen( dialog1_ptr,clear ) THEN
- drawmode := transparent_mode
- ELSE
- drawmode := opaque_mode;
- Draw_Mode( drawmode );
- blitmode := SHORT_TRUNC( 3.5 * drawmode );
-
- FOR i := draw TO text DO
- IF Chosen( dialog1_ptr,i ) THEN
- mode := i;
-
- ScrollBars;
- ChangeInfo;
- End_Mouse
- END;
-
- PROCEDURE Options;
- BEGIN
- Begin_Mouse;
- Blit_to_Memory;
- OptionDialog;
- ScrollBars;
- End_Mouse
- END;
-
- PROCEDURE GetEvent;
- VAR
- handle,xpos,ypos,width,height : integer;
- log,dummy : long_integer;
-
- PROCEDURE Arrow( VAR xpos,ypos,v_slide,h_slide : integer;
- x_limit,y_limit,x_slide,y_slide,x_inc,y_inc : integer );
- BEGIN
- CASE msg[4] OF
- 0: BEGIN ypos := 0; v_slide := 1 END;
- 1: BEGIN ypos := y_limit; v_slide := 1000 END;
- 2: BEGIN ypos := ypos-y_inc; v_slide := v_slide-y_slide END;
- 3: BEGIN ypos := ypos+y_inc; v_slide := v_slide+y_slide END;
- 4: BEGIN xpos := 0; h_slide := 1 END;
- 5: BEGIN xpos := x_limit; h_slide := 1000 END;
- 6: BEGIN xpos := xpos-x_inc; h_slide := h_slide-x_slide END;
- 7: BEGIN xpos := xpos+x_inc; h_slide := h_slide+x_slide END
- END;
- Limit( ypos,0,y_limit );
- Limit( xpos,0,x_limit );
- Limit( v_slide,1,1000 );
- Limit( h_slide,1,1000 );
- Wind_Set( window,WF_HSlide,h_slide,0,0,0 );
- Wind_Set( window,WF_VSlide,v_slide,0,0,0 )
- END;
-
-
- BEGIN
- event := EventMulti;
- handle := Front_Window;
-
- IF handle = window THEN
- BEGIN
- IF Click( rightbutton ) THEN
- BEGIN
- Begin_Mouse;
- Blit_to_Memory;
- screen := Physbase;
- log := Logbase;
- SetScreen( picture,picture,-1 );
- MouseVector( oldmouse,dummy );
- Set_Clip( 0,0,xmax+1,ymax+1 );
- WHILE Click( rightbutton ) DO ;
- WHILE NOT Click( rightbutton ) DO
- IF int_out[3] & leftbutton <> 0 THEN
- CASE mode OF
- magnify,pal,block: ;
- OTHERWISE: Sketch( int_out[4],int_out[1],int_out[2] )
- END;
- WHILE Click( rightbutton ) DO ;
- TrapMouse;
- SetScreen( log,screen,-1 );
- Set_Clip( gzz_x,gzz_y,gzz_w,gzz_h );
- Blit_to_Screen;
- End_Mouse
- END
- END
- ELSE
- IF keystate & ShiftAltCntrl = ShiftAltCntrl THEN
- BEGIN
- Hide_Mouse;
- screen := Physbase;
- SetScreen( -1,picture,-1 );
- Delay( 500 );
- Work_Rect( handle,xpos,ypos,width,height );
- CopyRaster( screen,picture,xpos,ypos,xpos,ypos,xpos,ypos,
- width,height,blitmode );
- IF keystate & rightshift <> 0 THEN
- SavePalette;
- WHILE keystate & ShiftAltCntrl <> 0 DO
- event := EventMulti;
- SetScreen( -1,screen,-1 );
- Show_Mouse
- END;
-
-
- IF event & E_Message <> 0 THEN
- CASE msg[0] OF
-
- AC_Open:
- IF window = No_Window THEN
- SketchOn;
-
- AC_Close:
- IF window <> No_Window THEN
- window := No_Window;
-
- WM_Closed:
- SketchOff;
-
- WM_Redraw:
- Redraw;
-
- WM_Arrowed:
- BEGIN
- Blit_to_Memory;
- CASE mode OF
- magnify:
- WITH mag DO
- Arrow( x_offset,y_offset,v_slide,h_slide,x_limit,y_limit,
- x_slide,y_slide,x_inc,y_inc );
- pal: ;
- OTHERWISE:
- WITH wind DO
- Arrow( x_offset,y_offset,v_slide,h_slide,x_limit,y_limit,
- x_slide,y_slide,x_inc,y_inc )
- END;
- Redraw
- END;
-
- WM_HSlid:
- BEGIN
- Blit_to_Memory;
- CASE mode OF
- magnify:
- WITH mag DO
- BEGIN
- h_slide := msg[4]+1;
- x_offset := Slider( h_slide,x_limit,WF_HSlide )
- END;
- pal: ;
- OTHERWISE:
- WITH wind DO
- BEGIN
- h_slide := msg[4]+1;
- x_offset := Slider( h_slide,x_limit,WF_HSlide )
- END
- END;
- Redraw
- END;
-
- WM_VSlid:
- BEGIN
- Blit_to_Memory;
- CASE mode OF
- magnify:
- WITH mag DO
- BEGIN
- v_slide := msg[4]+1;
- y_offset := Slider( v_slide,y_limit,WF_VSlide )
- END;
- pal: ;
- OTHERWISE:
- WITH wind DO
- BEGIN
- v_slide := msg[4]+1;
- y_offset := Slider( v_slide,y_limit,WF_VSlide )
- END
- END;
- Redraw
- END
- END;
-
- IF event & E_Keyboard <> 0 THEN
- CASE key OF
- F1,Help:
- SketchDialog;
- F2:
- Options;
- Escape:
- SketchOff;
- Undo:
- IF mode = pal THEN
- BEGIN
- SetPalette( Addr_Palette( sketchcolors ));
- Delay( 60 );
- StoreColors;
- ClearWindow;
- ColorPanel
- END
- ELSE
- Blit_to_Screen;
- Tab:
- IF rez = 2 THEN
- BEGIN
- dummy := SetGetColor( 0,( ~SetGetColor( 0,-1 ) & $777 ));
- GetColors( sketchcolors )
- END
- END;
-
- IF event & E_MRect_1 <> 0 THEN
- IF event & E_Button <> 0 THEN
- BEGIN
- IF my < ( y+inkwell_height+2 ) THEN
- BEGIN
- IF mx < ( x+patternspot-1 ) THEN
- SetColor( mx )
- ELSE
- BEGIN
- IF mx < Fx THEN
- SetPattern( keystate )
- ELSE
- BEGIN
- IF mx < Ox THEN
- SketchDialog
- ELSE
- Options
- END
- END
- END
- ELSE
- Sketch( keystate,mx,my )
- END
- END;
-
-
- BEGIN
- ap_id := Init_Gem;
- IF ap_id >= 0 THEN
- BEGIN
- desk_name := ' MultiPaint ';
- menu_id := Menu_Register( ap_id,desk_name );
- IF getrez < 2 THEN
- resource := 'color.rsc'
- ELSE
- resource := 'mono.rsc';
- IF Load_Resource( resource ) THEN
- BEGIN
- Find_Dialog( dialog1,dialog1_ptr );
- Find_Dialog( dialog2,dialog2_ptr )
- END
- ELSE
- WHILE TRUE DO
- IF EventMulti & E_Message <> 0 THEN
- dummy := Do_Alert( '[1][ | | No Resource File! | ][ Cancel ]',1 );
- window := No_Window;
- Initialize;
- WHILE TRUE DO
- GetEvent
- END
- END.
-