home *** CD-ROM | disk | FTP | other *** search
/ Kyūkyoku!! X68000 Emulator / X68000Book.dat / mac / OLS / X68000 / Ko-Window / kow142s.lzh / corlib / SheetCut.c < prev    next >
C/C++ Source or Header  |  1993-04-09  |  2KB  |  63 lines

  1. /*
  2.  
  3.     SheetCut.c    Ko-Window âëâCâuâëâè  1991 Å¼è}î┤öÄöV
  4.  
  5.         SPS-NET: SPS0783 COR.
  6.  
  7.  
  8.     Sheet é╠öCê╙é╠ê╩Æué⌐éτüAöCê╙é╠æσé½é│é╠ Sheet é≡ĵéΦÅoé╖üB
  9.  
  10. */
  11.  
  12.  
  13. #include    <wlib.h>
  14.  
  15. unsigned short    mask[]= {
  16.             0x0000, 0x8000, 0xc000, 0xe000,
  17.             0xf000, 0xf800, 0xfc00, 0xfe00,
  18.             0xff00, 0xff80, 0xffc0, 0xffe0,
  19.             0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff
  20.         };
  21.  
  22.  
  23. SheetCut( sp, cp, x, y )
  24. Sheet        *sp,    /* î│âfü[â^ */
  25.         *cp;    /* ÄµéΦÅoé╖âoâbâtâ@ */
  26. unsigned int    x,    /* É╪éΦÅoé╖ì└òW */
  27.         y;
  28. {
  29.     unsigned int    dy  = sp->hword+ sp->hword,
  30.             byte= dy*y + ((x&0xfff0)>>3),
  31.             bit = x & 15;
  32.     if( bit ){
  33.         unsigned int    bsize = (((bit+cp->h)&0xfff0)>>3)+2,
  34.                 i= cp->v;
  35.         unsigned short    sbuf[64],
  36.                 *sptr= (unsigned short*)(((char*)sp->buf1)+byte),
  37.                 *sptr2=(unsigned short*)(((char*)sp->buf2)+byte),
  38.                 *cptr= (unsigned short*)cp->buf1,
  39.                 *cptr2=(unsigned short*)cp->buf2,
  40.                 mskpat= mask[ cp->h - (cp->hword-1)*16 ];
  41.  
  42.         do{
  43.             memcpyW( bsize>>1, sbuf, sptr );
  44.             shiftL( bit, bsize, sbuf );
  45.             memcpyW( cp->hword, cptr, sbuf );
  46.             cptr[ cp->hword-1 ] &= mskpat;
  47.             cptr+= cp->hword;
  48.             sptr+= sp->hword;
  49.             memcpyW( bsize>>1, sbuf, sptr2 );
  50.             shiftL( bit, bsize, sbuf );
  51.             memcpyW( cp->hword, cptr2, sbuf );
  52.             cptr2[ cp->hword-1 ] &= mskpat;
  53.             cptr2+= cp->hword;
  54.             sptr2+= sp->hword;
  55.         }while( --i );
  56.     }else{
  57.         dy= (sp->hword - cp->hword)*2;
  58.         Scpy( dy, cp->v, cp->buf1, ((char*)sp->buf1)+byte, cp->hword );
  59.         Scpy( dy, cp->v, cp->buf2, ((char*)sp->buf2)+byte, cp->hword );
  60.     }
  61. }
  62.  
  63.