home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / ms_dos / fmgraph / g_osectr.c < prev    next >
Text File  |  1990-06-14  |  1KB  |  71 lines

  1. #include    <stdio.h>
  2. #include    <math.h>
  3. #include    <dos.h>
  4.  
  5. struct FIXED {
  6.     unsigned    major,minor;
  7. };
  8.  
  9. struct OVALSECTOR {
  10.     unsigned    type;
  11.     int        cx,cy,dx,nul1,nul2,dy;
  12.     struct FIXED    strd,edrd;
  13.     unsigned char    sctrmode,reserve;
  14. };
  15.  
  16. extern    unsigned    char    gds_fshift;
  17. extern    unsigned    gds_wrkoff;
  18. extern    unsigned    gds_wrkseg;
  19.  
  20. int    g_oval_sector(int x,int y,int rx,int ry,double start,double end)
  21. {
  22.     union REGS    reg;
  23.     struct SREGS    seg;
  24.     double    iwork,fwork;
  25.     struct {
  26.         unsigned    len;
  27.         struct OVALSECTOR    sctr;
  28.     }    gdata;
  29.  
  30.     segread(&seg);
  31.     reg.h.ah=gds_fshift+0x0f;
  32.     reg.x.di=(unsigned)&gdata;
  33.     seg.ds=seg.ss;
  34.     gdata.len=24;
  35.     gdata.sctr.type=0x4276;
  36.     gdata.sctr.cx=x;
  37.     gdata.sctr.cy=y;
  38.     gdata.sctr.dx=rx;
  39.     gdata.sctr.nul1=0;
  40.     gdata.sctr.nul2=0;
  41.     gdata.sctr.dy=ry;
  42.     if(start>=0){
  43.         fwork=modf(start,&iwork);
  44.         gdata.sctr.strd.major=0;
  45.     }
  46.     else{
  47.         fwork=fabs(start);
  48.         fwork=modf(fwork,&iwork);
  49.         gdata.sctr.strd.major=0x8000;
  50.     }
  51.     gdata.sctr.strd.major+=(unsigned)iwork;
  52.     gdata.sctr.strd.minor=(unsigned)(fwork*65536.0);
  53.     if(end>=0){
  54.         fwork=modf(end,&iwork);
  55.         gdata.sctr.edrd.major=0;
  56.     }
  57.     else{
  58.         fwork=fabs(end);
  59.         fwork=modf(fwork,&iwork);
  60.         gdata.sctr.edrd.major=0x8000;
  61.     }
  62.     gdata.sctr.edrd.major+=(unsigned)iwork;
  63.     gdata.sctr.edrd.minor=(unsigned)(fwork*65536.0);
  64.     gdata.sctr.sctrmode=0;
  65.     gdata.sctr.reserve=0;
  66.     reg.x.bx=gds_wrkoff;
  67.     seg.es=gds_wrkseg;
  68.     int86x(0x92,®,®,&seg);
  69.     return (int)reg.h.ah;
  70. }
  71.