Beispiel #1
0
/*
 * Display msg with color at coordinates (y, x)
 */
void ossdsp(int y, int x, int color, char *s)
{
    if (bios_flag) {
        __dpmi_regs regs;

        while (*s) {
            ossloc(y, x++);
            regs.h.ah = B_WRITECHAR;
            regs.h.al = *s++;
            regs.h.bh = video_page;
            regs.h.bl = color;
            regs.x.cx = 1;              /* count = 1 */
            __dpmi_int(0x10, &regs);
        }
    } else {
        union vcell vc;
        unsigned long vp;
        char *p = s;

        vp = scrbase + ((y * 80 + x) << 1);
        vc.ca.vattr = color;
        _farsetsel(_go32_conventional_mem_selector());
        while (*p) {
            vc.ca.vchar = *p++;
            _farnspokew(vp, vc.s);
            vp += 2;
        }
        ossloc(y, x + (p - s - (*s ? 1 : 0)));
    }
}
Beispiel #2
0
void tui_display(int x, int y, int len, const char *format, ...)
{
    BYTE attr_byte = (BYTE)current_attr;
    unsigned long addr = screen_addr(x, y);
    char *buf;
    int i, buf_len;
    va_list vl;

    va_start(vl, format);
    buf = lib_mvsprintf(format, vl);
    buf_len = strlen(buf);
    if (len == 0)
        len = buf_len;
    else if (buf_len > len)
        buf_len = len;

    _farsetsel(_dos_ds);
    for (i = 0; i < buf_len; i++) {
        _farnspokeb(addr, buf[i]);
        _farnspokeb(addr + 1, attr_byte);
        addr += 2;
    }
    for (; i < len; i++) {
        _farnspokeb(addr, ' ');
        _farnspokeb(addr + 1, attr_byte);
        addr += 2;
    }
    lib_free(buf);
}
Beispiel #3
0
void mywrite(unsigned char *s)
{
   int p;

   while ((*s) && (x_pos < 0)) {
      x_pos++;
      s++;
   }

   p = SCRN_ADDR(x_pos, y_pos);

   _farsetsel(dos_seg);

   while ((*s) && (x_pos < screen_w)) { 
      _farnspokew(p, (attrib<<8) | *s);
      p += 2;
      x_pos++;
      s++;
   }

   while (*s) {
      x_pos++;
      s++;
   }
}
Beispiel #4
0
int
closesocket(SOCKET s)
{
   RTQ_NODE *n = MGenGetNode(IDLE_QUEUE);
   LPCData  *p;
   LPCReturn *r;
   int       retVal;

   _farsetsel(flat_selector);
   SocketError = 0;
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service, LPC_SOCKCLOSE);
   FARPOKL(p->Data, s);

   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = MGenGetNode(REC_QUEUE)) == 0)
      Yield();

   r = (LPCReturn *) FARPKL(&n->rtqDatum);

   if (FARPKS(&r->error) != LPC_NOERROR) {
      return -1;
   }

   retVal = FARPKL(r->Data);

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
}
Beispiel #5
0
void fb_hFarMemSetW(unsigned short selector, unsigned long dest, unsigned short word_to_set, size_t words)
{
	unsigned long addr = dest;
	int i;

	_farsetsel(selector);

	for (i = 0; i < words; i++, addr += 2) {
		_farnspokew(addr, word_to_set);
	}
}
Beispiel #6
0
int
sendto(SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen)
{
   int i;
   int outQ;
   WinSockData *data;

   SocketError = 0;
   _farsetsel(flat_selector);
   if (!SockMap)
      GetSocketMap();

   for (i = 0; i < MAXSOCKETS; i++) {
      if (FARPKL(&SockMap->sock[i]) == s) {
         break;
      }
   }

   if (i == MAXSOCKETS) {
      SocketError = WSAENOTSOCK;
      return SOCKET_ERROR;
   }

   outQ = i + MAXSOCKETS;

   if (MGenGetQueueCtr(outQ) >= QLIMIT) {
      SocketError = WSAEWOULDBLOCK;
      return SOCKET_ERROR;
   }

   data = GetFreeBufferToQueue(PRIVATEQ, len + sizeof(WinSockData));

   if (!data) {
      SocketError = WSAEWOULDBLOCK;
      return SOCKET_ERROR;
   }

   FARPOKL(&data->s, s);
   FARPOKL(&data->len, len);
   if (to) {
      fmemcpyto(&data->addr, to, tolen);
      FARPOKL(&data->addrlen, tolen);
   } else {
      FARPOKL(&data->addrlen, 0);
   }

   FARPOKL(&data->flags, flags);

   fmemcpyto(data->data, buf, len);

   MGenMoveTo(PRIVATEQ, outQ);

   return len;
}
Beispiel #7
0
void fb_hFarMemSet(unsigned short selector, unsigned long dest, unsigned char char_to_set, size_t bytes)
{
	unsigned long addr = dest;
	int i;

	_farsetsel(selector);

	for (i = 0; i < bytes; i++, addr++) {
		_farnspokeb(addr, char_to_set);
	}
}
Beispiel #8
0
void tui_put_char(int x, int y, BYTE c)
{
    unsigned long addr = screen_addr(x, y);
    BYTE attr_byte = (BYTE)current_attr;

    _farsetsel(_dos_ds);
    if (c>127)
      _farnspokeb(addr, tui_ascii_conversion_table[c-128]);
    else
      _farnspokeb(addr, c);
    _farnspokeb(addr + 1, attr_byte);
}
Beispiel #9
0
void del_to_eol()
{
   int c = MAX(x_pos, 0);
   int p = SCRN_ADDR(c, y_pos);

   _farsetsel(dos_seg);

   while (c++ < screen_w) { 
      _farnspokew(p, attrib<<8);
      p += 2;
   }
}
Beispiel #10
0
void main() {
  int scrwid=320;
  int scrhei=200;
  int indent=(scrwid-scrhei)/2;
  float cenx=0;
  float ceny=0;
  float wid=0.75;
  float hei=0.75;
  float left=cenx-wid;
  float right=cenx+wid;
  float top=ceny-hei;
  float bottom=ceny+hei;
  float dslice=0;
  float front=-1.5;
  float back=-0.5;
  float scale=2.0/(back-front);
  int steps=250;
  JBmp *b=new JBmp(scrwid,scrhei);
  allegrosetup(scrwid,scrhei);
  makepalette(&greypalette);
  _farsetsel(screen->seg);
  randomise();
//  Quaternion c=*new Quaternion(floatrnd(-2.0,2.0),floatrnd(-2.0,2.0),floatrnd(-2.0,2.0),floatrnd(-2.0,2.0));
  Quaternion c=*new Quaternion(floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5));
  do {
  c=c*Quaternion(0.99,0,0,0)+Quaternion(floatrnd(-.05,.05),floatrnd(-.05,.05),floatrnd(-.05,.05),floatrnd(-.05,.05));
  dslice=c.d;
  for (int i=0;i<scrhei;i+=2) {
    for (int j=0;j<scrhei;j+=2) {
      int col=0;
      for (int k=0;k<steps && col==0;k++) {
        float x=left+2.0*wid*i/(float)scrhei;
        float y=top+2.0*hei*j/(float)scrhei;
        float z=front+(back-front)*k/(float)steps;
        float scrz=(z-front)*scale+1.0;
        x=x/z; y=y/z;
        int r=julquat(Quaternion(x,y,z,dslice),Quaternion(x,y,z,dslice));
        if (r==0)
          col=255.0*(1.0-(float)k/(float)steps);
      }
      b->setpixel(indent+i,j,col);
      b->setpixel(indent+i+1,j,col);
      b->setpixel(indent+i,j+1,col);
      b->setpixel(indent+i+1,j+1,col);
      if (key[KEY_SPACE])
        exit(0);
    }
    b->writetoscreen();
  }
  } while (!key[KEY_SPACE]);
  allegro_exit();
}
Beispiel #11
0
void tui_vline(int x, int y, BYTE c, int count)
{
    unsigned long addr = screen_addr(x, y);
    BYTE attr_byte = (BYTE)current_attr;
    int i;

    _farsetsel(_dos_ds);
    for (i = 0; i < count; i++) {
        _farnspokeb(addr, c);
        _farnspokeb(addr + 1, attr_byte);
        addr += tui_num_cols();
    }
}
Beispiel #12
0
void swapBuff() {
	int i;
	long next, old;
	_farsetsel(my_video_ds);
	for (i = 0; i < 1024*768/4; i++) { 
		next = ((long*)doubleBuff)[i];
		old = ((long*)prevBuff)[i];
		if (next != old) {
			_farnspokel(i*4, next);
			((long*)prevBuff)[i] = next;
		}
	}	
}
Beispiel #13
0
void tui_make_shadow(int x, int y, int width, int height)
{
    int i, j;

    _farsetsel(_dos_ds);
    for (i = 0; i < height; i++) {
        int addr = screen_addr(x, y + i) + 1;

        for (j = 0; j < width; j++, addr += 2) {
            _farnspokeb(addr, make_attr(DARKGRAY, BLACK, 0));
        }
    }
}
Beispiel #14
0
int main()
{
	int i;
	int ids[BLOB_COUNT];
	__dpmi_regs regs;
	
	clrscr();
	printf("\nLWP: Example 3.  Pre-emptive/Cooperative\n");
	printf("This program spawns %d threads that each draw\n", BLOB_COUNT);
	printf("a dot on the screen that moves in a random direction.\n");
	printf("Each thread yields after it draws a pixel, to smooth\n");
	printf("out the dot motion\n");
	printf("Press any key to continue...");
	fflush(stdout);
	getch();
	regs.x.ax = 0x13;
	srandom(time(0));
	__dpmi_int(0x10, &regs);
	lwpInit(RTC128, 1);
	lwpEnterCriticalSection();
	_farsetsel(_dos_ds); 
	lwpLeaveCriticalSection();
	for(i=0;(i<BLOB_COUNT) && !kbhit();i++)
		{
		ids[i] = lwpSpawn(blobProc, NULL, 4096, 1, TRUE);
		lwpYield();  /* let the blob move a little */
		}
	while(!kbhit())
		{
		if(plotCount == BLOB_COUNT)
			{
			plotCount = 0;
			waitVBL(); 
			}	
		plotCount++;
		lwpYield();
		}
	/* key was hit, all other threads start dying here */

	while(lwpThreadCount() > 0) 
		{
		lwpYield();  /* wait for all the other threads to die */
		}

	getch();
	lwpEnterCriticalSection();
	regs.x.ax = 0x3;
	__dpmi_int(0x10, &regs);
	lwpLeaveCriticalSection();
	return(0);
}
Beispiel #15
0
void tui_area_put(tui_area_t a, int x, int y)
{
    BYTE *p = a->mem;
    int i, j;

    _farsetsel(_dos_ds);

    for (i = 0; i < a->height; i++) {
        int addr = screen_addr(x, y + i);

        for (j = 0; j < 2 * a->width; j++)
            _farnspokeb(addr + j, *(p++));
    }
}
Beispiel #16
0
int
gethostname(char *name, int namelen)
{
   RTQ_NODE *n;
   LPCData  *p;
   LPCReturn *r;
   GetHostNameRet  *ret;
   int       retVal;
   char  *s;

   _farsetsel(flat_selector);
   SocketError = 0;
   n = (RTQ_NODE *) MGenGetNode(IDLE_QUEUE);
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service,LPC_SOCKGETHOSTNAME);
   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = (RTQ_NODE *) (MGenGetNode(REC_QUEUE))) == 0)
      Yield();

   r = (LPCReturn *) FARPKL(&n->rtqDatum);

   if (FARPKS(&r->error) != LPC_NOERROR) {
      return -1;
   }

   ret = (GetHostNameRet *) r->Data;

   retVal = FARPKL(&ret->retVal);

   s = ret->name;

   fstrncpyfrom(name, s, namelen);

#if 0
   len = strlen(ret->name);

   if (len > namelen)
      memcpy(name, ret->name, ret->namelen);
   else
      strcpy(name, ret->name);
#endif

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
}
Beispiel #17
0
int
recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from,
         int *fromlen)
{
   int i;
   RTQ_NODE *n;
   WinSockData  *data;
   int  bytesRead;

   SocketError = 0;
   _farsetsel(flat_selector);
   if (!SockMap)
      GetSocketMap();

   for (i = 0; i < MAXSOCKETS; i++) {
      if (FARPKL(&(SockMap->sock[i])) == s)
         break;
   }

   if (i == MAXSOCKETS)
      return SOCKET_ERROR;

   // pick up node
   n = MGenGetNode(i);
   if (n == 0) {
      SocketError = WSAEWOULDBLOCK;
      return -1;
   }

   data = (WinSockData *) FARPKL(&n->rtqDatum);
   bytesRead = FARPKL(&data->len);

   if (from) {
      fmemcpyfrom(from, &data->addr, sizeof(struct sockaddr));
   }

   if (fromlen) {
      *fromlen = FARPKL(&data->addrlen);
   }

   fmemcpyfrom(buf, data->data, len > bytesRead ? bytesRead : len);

   if ((flags & MSG_PEEK) == 0) {
      FreeBufferFromQueue(i);
   }

   return bytesRead;
}
Beispiel #18
0
static int
readCharacters_PcBiosScreen (const ScreenBox *box, ScreenCharacter *buffer) {
  unsigned offset = ScreenPrimary;
  ScreenDescription description;
  int row, col;
  describe_PcBiosScreen(&description);
  if (!validateScreenBox(box, description.cols, description.rows)) return 0;
  _farsetsel(_go32_conventional_mem_selector());
  for (row=box->top; row<box->top+box->height; ++row)
    for (col=box->left; col<box->left+box->width; ++col) {
      buffer->text = _farnspeekb(offset + row*description.cols*2 + col*2);
      buffer->attributes = _farnspeekb(offset + row*description.cols*2 + col*2 + 1);
      buffer++;
    }
  return 1;
}
Beispiel #19
0
void blobProc(void *p)
{
	int x, y, xspeed,yspeed ;
	char col;
	lwpEnterCriticalSection();	
        x      = (int) (319 * (float)((float) random() / (float) RAND_MAX ));
	y      = (int) (199 * (float)((float) random() / (float) RAND_MAX ));
	col    = (int) (255 * (float)((float) random() / (float) RAND_MAX ));	
	xspeed = (int) (3   * (float)((float) random() / (float) RAND_MAX ));	
	yspeed = (int) (3   * (float)((float) random() / (float) RAND_MAX ));	
	_farsetsel(_dos_ds); 
	lwpLeaveCriticalSection();
        /* loop until keypress */
	while(!kbhit())
		{
		putpixel(x,y,0);
		plotCount++;
		x+=xspeed;
		if(x>=319)
			{
			xspeed=-xspeed;
			x = 319;
			}
		if(x<=0)
			{
			xspeed=-xspeed;
			x = 0;
			}	
		y+=yspeed;
		if(y>=199)
			{
			yspeed=-yspeed;
			y=199;
			}
		if(y<=0)
			{
			yspeed=-yspeed;
			y=0;
			}
		putpixel(x,y,col);	
		lwpYield();
		}
	putpixel(x,y,0); 
 /* erase pixel */
 /* thread dies here */
}	
Beispiel #20
0
static int Clear(SexyAL_device *device)
{
    CMI8738_Driver_t *ds = (CMI8738_Driver_t *)device->private_data;
    const uint32_t base = ds->dmabuf.rm_segment << 4;
    const uint32_t siz = ds->dmabuf.size << 4;

    Pause(device, true);

    _farsetsel(_dos_ds);
    for(unsigned i = 0; i < siz; i += 4)
        _farnspokel(base + i, 0);

    UpdateReadCounter(ds);
    ds->write_counter = ds->read_counter;

    return(1);
}
Beispiel #21
0
void main() {
  int scrwid=320;
  int scrhei=200;
  float cenx=-0.5;
  float ceny=0;
  float wid=2.0;
  float hei=1.5;
  float left=cenx-wid;
  float right=cenx+wid;
  float top=ceny-hei;
  float bottom=ceny+hei;
  float front=-1.0;
  float back=0.5;
  float scale=2.0/(2.0*front);
  float crazy=0.1234567;
  int steps=20;
  int jump=1;
  int frames=30;
  JBmp *b=new JBmp(scrwid,scrhei);
  allegrosetup(scrwid,scrhei);
//  makepalette(&greypalette);
  _farsetsel(screen->seg);
  randomise();
  Map2d<float> *map=new Map2d<float>(scrhei,scrhei);
  for (int frame=0;frame<frames;frame++) {
    float angle=pi*(float)frame/(float)frames;
    for (int i=0;i<scrwid;i+=jump) {
      for (int j=0;j<scrhei;j+=jump) {
        // b->setpixelud(indent+i,j,255);
        // b->writetoscreen();
        int col=0;
        V3d tmp=V3d(left+2.0*wid*i/(float)scrwid,top+2.0*hei*j/(float)scrhei,0);
        tmp=V3d::rotate(tmp,V3d(0,1,0),angle);
        current=Quaternion(tmp.x,tmp.y,tmp.z,0);
        b->bmp[j][i]=julquat(Quaternion(0,0,0,0));
        if (key[KEY_SPACE])
          exit(0);
      }
    b->writetoscreen();
    }
//    PALETTE pal;
//    get_palette(pal);
//    save_bitmap(getnextfilename("bmp"),screen,pal);
  } while (!key[KEY_SPACE]);
  allegro_exit();
}
Beispiel #22
0
void main() {
  int scrwid=320;
  int scrhei=200;
  float cenx=0;
  float ceny=0;
  float wid=2.0;
  float hei=1.5;
  float left=cenx-wid;
  float right=cenx+wid;
  float top=ceny-hei;
  float bottom=ceny+hei;
  JBmp *b=new JBmp(scrwid,scrhei);
  allegrosetup(scrwid,scrhei);
//  makepalette(&greypalette);
  _farsetsel(screen->seg);
  randomise();
  Complex c=Complex(floatrnd(-4.0,4.0),floatrnd(-4.0,4.0));
  do {
  c=c*Complex(0.99,0)+Complex(floatrnd(-.5,.5),floatrnd(-.5,.5));
  for (int i=0;i<scrwid;i+=2) {
    for (int j=0;j<scrhei;j+=2) {
      float x=left+2.0*wid*i/(float)scrwid;
      float y=top+2.0*hei*j/(float)scrhei;
      Complex z=Complex(x,y);
      int k=0;
      bool over=false;
      do {
        k++;
        z=z*z+c;
        if (k>255)
          over=true;
      } while (!over && !(z.mod()>2.0));
      if (over)
        k=0;
      b->setpixel(i,j,k);
      b->setpixel(i+1,j,k);
      b->setpixel(i,j+1,k);
      b->setpixel(i+1,j+1,k);
      if (key[KEY_SPACE])
        break;
    }
  }
  b->writetoscreen();
  } while (!key[KEY_SPACE]);
  allegro_exit();
}
Beispiel #23
0
unsigned long inet_addr(const char *cp)
{
	int ret;
	unsigned int ha1, ha2, ha3, ha4;
	unsigned long ipaddr;

	ret = sscanf(cp, "%d.%d.%d.%d", &ha1, &ha2, &ha3, &ha4);
	if (ret != 4)
		return -1;
	ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
	return ipaddr;
#if 0
   RTQ_NODE *n = MGenGetNode(IDLE_QUEUE);
   LPCData  *p;
   LPCReturn *r;
   int       retVal;

   SocketError = 0;
   _farsetsel(flat_selector);
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service, LPC_SOCKINETADDR);

   fstrcpyto(p->Data, cp);

   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = MGenGetNode(REC_QUEUE)) == 0)
      Yield();

   r = (LPCReturn *) FARPKL(&n->rtqDatum);

   if (FARPKS(&r->error) != LPC_NOERROR) {
      return -1;
   }

   retVal = FARPKL(r->Data);

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
 #endif
}
Beispiel #24
0
int
ioctlsocket(SOCKET s, long cmd, unsigned long *argp)
{
   RTQ_NODE *n = MGenGetNode(IDLE_QUEUE);
   LPCData  *p;
   LPCReturn *r;
   IoctlArgs  *args;
   int       retVal;

   SocketError = 0;
   _farsetsel(flat_selector);
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service, LPC_SOCKIOCTL);
   args = (IoctlArgs *) p->Data;
   FARPOKL(&args->s, s);
   FARPOKL(&args->cmd, cmd);

   switch(cmd) {
   case FIONBIO:
      FARPOKL(args->data, *argp);
      break;
   default:
      return SOCKET_ERROR;
   }

   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = MGenGetNode(REC_QUEUE)) == 0)
      Yield();

   r = (LPCReturn *) FARPKL(&n->rtqDatum);


   retVal = FARPKL(r->Data);

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
}
Beispiel #25
0
void main() {

  allegrosetup(scrwid,scrhei);
  makepalette(&greypalette);
  _farsetsel(screen->seg);
  PALETTE pal;
  get_palette(pal);

  randomise(0.456);
  for (int i=0;i<20;i++) {
    S s=S(V3d::randomvolume(1),0,0);
    S v=S(V3d(0,0,0),0,0);
    xs+s;
    xvs+v;
  }
  for (int rndloop=0;rndloop<100;rndloop++) {
    for (int i=0;i<xs.len;i++) {
      S *v=xvs.p2num(i);
      S *x=xs.p2num(i);
      domovement(v,x);
    }
  }
  do {

    rend->clear(crazy);

    for (int i=0;i<scrhei;i+=jump) {
      for (int j=0;j<scrhei;j+=jump) {
        fillsquare(i,j,jump,jump);
      }
      b->writetoscreen();
    }

    for (int lkg=0;lkg<1;lkg++)
    for (int i=1;i<=xs.len;i++) {
      S *v=xvs.p2num(i);
      S *x=xs.p2num(i);
      domovement(v,x);
    }
    b->writefile(getnextfilename("bmp"));
  } while (!key[KEY_ESC]);
}
Beispiel #26
0
struct hostent *
gethostbyaddr(const char *addr, int len, int type)
{
   RTQ_NODE *n = MGenGetNode(IDLE_QUEUE);
   LPCData  *p;
   LPCReturn *r;
   GetHostByAddrArgs *args;
   struct hostent *retVal;

   SocketError = 0;
   _farsetsel(flat_selector);
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service, LPC_SOCKGETHOSTBYADDR);
   args = (GetHostByAddrArgs *) p->Data;
   FARPOKL(&args->len, len);
   FARPOKL(&args->type, type);
   fmemcpyto(args->addr, addr, len);

   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = MGenGetNode(REC_QUEUE)) == 0)
      Yield();
   r = (LPCReturn *) FARPKL(&n->rtqDatum);
   retVal = (struct hostent *) r->Data;

   if (FARPKL(&retVal->h_name) == 0) {
      retVal = 0;
   } else {
      ZapHostEnt();

      ReconstructHostEnt(&HostEnt, (void *) retVal);
      retVal = &HostEnt;
   }

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
}
Beispiel #27
0
void keep(unsigned char status, unsigned size)
{
  __dpmi_regs regs;

  _farsetsel(_dos_ds);

  /* Keep size default is current PSP block size */
  if(_farnspeekw(_go32_info_block.linear_address_of_original_psp - 15) !=
     _go32_info_block.linear_address_of_original_psp / 16)
    /* Not a real PSP? attempt to continue */
    regs.x.dx = (_go32_info_block.size_of_transfer_buffer + 256) / 16;
  else
    regs.x.dx = _farnspeekw(_go32_info_block.linear_address_of_original_psp - 13);

  /* Default is to keep PSP and transfer buffer, but the user may want to
     not use and release transfer buffer to decrease DOS footprint.  */
  if(size >= 16 && size < regs.x.dx)
    regs.x.dx = size;

  regs.x.ax = 0x3100 + status;
  __dpmi_int(0x21, &regs);
}
Beispiel #28
0
SOCKET
socket(int af, int type, int protocol)
{
   RTQ_NODE *n = MGenGetNode(IDLE_QUEUE);
   LPCData  *p;
   LPCReturn *r;
   SocketArgs  *args;
   int       retVal;

   _farsetsel(flat_selector);
   SocketError = 0;
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service, LPC_SOCKSOCKET);
   args = (SocketArgs *) p->Data;
   FARPOKL(&args->af, af);
   FARPOKL(&args->type, type);
   FARPOKL(&args->protocol, protocol);

   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = MGenGetNode(REC_QUEUE)) == 0)
      Yield();

   r = (LPCReturn *) FARPKL(&n->rtqDatum);


   if (FARPKS(&r->error) != LPC_NOERROR) {
      return -1;
   }

   retVal = FARPKL(r->Data);

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
}
Beispiel #29
0
int
getsockname(SOCKET s, struct sockaddr *name, int *namelen)
{
   RTQ_NODE *n = MGenGetNode(IDLE_QUEUE);
   LPCData  *p;
   LPCReturn *r;
   GetSockNameRet  *ret;
   int       retVal;

   SocketError = 0;
   _farsetsel(flat_selector);
   p = (LPCData *) FARPKL(&n->rtqDatum);
   SetLPCData(p);
   FARPOKL(&p->service, LPC_SOCKGETSOCKNAME);
   FARPOKL(p->Data, s);

   MGenMoveTo(IDLE_QUEUE, SEND_QUEUE);
   PostWindowsMessage();

   while ((n = MGenGetNode(REC_QUEUE)) == 0)
      Yield();


   r = (LPCReturn *) FARPKL(&n->rtqDatum);

   if (FARPKS(&r->error) != LPC_NOERROR) {
      return -1;
   }

   ret = (GetSockNameRet *) r->Data;
   retVal = FARPKL(&ret->retVal);
   fmemcpyfrom(name, ret->name, FARPKL(&ret->namelen));
   *namelen = FARPKL(&ret->namelen);

   // get ready for next call
   MGenMoveTo(REC_QUEUE, IDLE_QUEUE);

   return retVal;
}
Beispiel #30
0
void tui_area_get(tui_area_t *a, int x, int y, int width, int height)
{
    BYTE *p;
    int i, j;

    if (*a == NULL) {
        *a = lib_malloc(sizeof (struct tui_area));
        (*a)->mem = lib_malloc(2 * width * height);
    } else {
        (*a)->mem = lib_realloc((*a)->mem, 2 * width * height);
    }
    (*a)->width = width;
    (*a)->height = height;

    _farsetsel(_dos_ds);

    for (p = (*a)->mem, i = 0; i < height; i++) {
        int addr = screen_addr(x, y + i);

        for (j = 0; j < 2 * width; j++)
            *(p++) = _farnspeekb(addr + j);
    }
}