Mail Archives: djgpp/1997/03/03/10:45:27
>
> On Mon, 3 Mar 1997, Christoph Kukulies wrote:
>
> > I read djgppfaq.txt chapter 18.2 and as a result I thought I
> > had it working but the combo of my program and the driver
> > seems to be very unstable. I cannot invoke the program twice.
>
> Please post more of your code (the fragment you showed seems OK). For
> example, how do you move data from and to the transfer buffer?
I appended the complete (quick and dirty) test program.
The driver requires that the X-Y-Z ccordinates are passed in a real mode
buffer:
Lower Address Higher Address
+---------------+----------------+--------------+
|x|x|x|x|x|x|x|x|y|y|y|y|y|y|y|y|z|z|z|z|z|z|z|z|
+---------------+----------------+--------------+
>
> Also, can you see where does the program hang? Is it in your code, or
> inside the call to `__dpmi_int'?
My program (see below) is so straight that, if it hangs it can only
hang in their driver (or dpmi_int) - presumably :-)
>
> > BTW, why is __tb>>4 anded with 0xffff? Since it is an address below 1MB
> > supplied by go32 the by 4 shifted value can never have any bits set
> > that would be masked off by 0xffff.
>
> You forget the memory mapping. The transfer buffer is physically indeed
> below 1MB mark, but its logical address is not guaranteed to have all the
> high bits zeroed.
>
> > Does it matter whether cwsdpmi is loaded once in autoexec (cwsdpmi -p)
> > or having it just in the path?
>
> Shouldn't matter at all.
>
--
Chris Christoph P. U. Kukulies kuku AT gil DOT physik DOT rwth-aachen DOT de
/*******************************************/
/* */
/* Steuerprogramm fuer MPK3 3-Achsen Tisch */
/* Ch. Kukulies 25.2.97 */
/* */
/*******************************************/
#include <stdio.h>
#include "isl.h"
#include <dpmi.h>
#include <go32.h>
#define ESC 27
#define UP 328
#define DOWN 336
#define LEFT 331
#define RIGHT 333
#define _AL r.h.al
#define _AH r.h.ah
#define _BL r.h.bl
#define _BH r.h.bh
#define _CL r.h.cl
#define _CH r.h.ch
#define _DL r.h.dl
#define _DH r.h.dh
#define _CX r.x.cx
#define _DX r.x.dx
#define X(x) *((char *)__tb) = x&0xff;*((char *)__tb+1)=(x>>8)&0xff;\
*((char *)__tb+2) = (x>>16)&0xff;*((char *)__tb+3)=(x>>24)&0xff;
#define Y(x) *((char *)__tb+4) = x&0xff;*((char *)__tb+1+4)=(x>>8)&0xff;\
*((char *)__tb+2+4) = (x>>16)&0xff;*((char *)__tb+3+4)=(x>>24)&0xff;
#define Z(x) *((char *)__tb+8) = x&0xff;*((char *)__tb+1+8)=(x>>8)&0xff;\
*((char *)__tb+2+8) = (x>>16)&0xff;*((char *)__tb+3+8)=(x>>24)&0xff;
#define ISEL_CMD __dpmi_int(0x78,&r)
main()
{
int key;
__dpmi_regs r;
int xpos=0,ypos=0,zpos=0;
isl_wakeup();
r.x.ax=1;
ISEL_CMD;
printf("TREIBERVERSION - %c%c%c%c%c%c\n",_BH,_BL,_CH,_CL,_DH,_DL);
r.x.ax=2;
ISEL_CMD;
printf("TREIBERRESET OK (%d)\n",_AL);
r.x.ax=9; /* Teachin AUS */
r.x.bx=0;
ISEL_CMD;
r.x.ax=6;
r.x.bx=0;
r.h.bl=7; /* x,y,z- Referenzfahrt */
ISEL_CMD;
printf("REFERENZFAHRT (%d)\n",_AL);
printf("%08lhx %04x %02x\n",__tb,(__tb>>4)&0xffff,__tb&0x0f);fflush(stdout);
r.x.ax=5;
r.x.bx=0;
ISEL_CMD;
printf("TREIBERSTATUS (%d) cx=%08lx dx=%08lx\n",_AL,_CX,_DX);
while(1){
while (!(kbhit()))
;
key=getkey();
printf("key=%d\n",key);fflush(stdout);
if(key==ESC)
break;
switch(key) {
case DOWN :
zpos--;
if(zpos<0)
zpos=0;
break;
case UP :
zpos++;
X(xpos);
Y(ypos);
Z(zpos);
r.x.ax=24;
r.x.cx=__tb&0x0f;
r.x.bx=(__tb>>4)&0xffff;
ISEL_CMD;
break;
case LEFT :
case RIGHT :
break;
default :
break;
}
printf("ABSOLUTE LINEARNORMALBEWEGUNG (%d)",_AL);
fflush(stdout);
r.x.ax=18;
r.x.cx=__tb&0x0f;
r.x.bx=(__tb>>4)&0xffff;
ISEL_CMD;
printf(" %08lx %08lx %08lx\n",
*((unsigned long *)__tb+0),
*((unsigned long *)__tb+1),
*((unsigned long *)__tb+2));
fflush(stdout);
}
isl_sleep();
}
isl_wakeup()
{
__dpmi_regs r;
r.x.ax=47;
r.x.bx=0; /* wakeup modus */
ISEL_CMD;
}
isl_sleep()
{
__dpmi_regs r;
r.x.ax=47;
r.x.bx=1; /* sleep modus */
ISEL_CMD;
}
- Raw text -