Beispiel #1
0
void
load_command(regcontext_t *REGS, int run, int fd, char *cmd_name, 
	     u_short *param, char **argv, char **envs)
{
    struct exehdr hdr;
    int min_memory, max_memory;
    int biggest;
    int envseg;
    char *psp;
    int text_size = 0;
    int i;
    int start_segment;
    int exe_file;
    char *p;
    int used, n;
    char *fcb;
    int newpsp;
    u_short init_cs, init_ip, init_ss, init_sp, init_ds, init_es;

    if (envs)
	envseg = make_environment(cmd_name, envs);
    else
	envseg = env_s[curpsp];

    /* read exe header */
    if (read (fd, &hdr, sizeof hdr) != sizeof hdr)
	fatal ("can't read header\n");
    
    /* proper header ? */
    if (hdr.magic == 0x5a4d) {
	exe_file = 1;
	text_size = (hdr.size - 1) * 512 + hdr.bytes_on_last_page
	    - hdr.hdr_size * 16;
	min_memory = hdr.min_memory + (text_size + 15)/16;
	max_memory = hdr.max_memory + (text_size + 15)/16;
    } else {
	exe_file = 0;
	min_memory = 64 * (1024/16);
	max_memory = 0xffff;
    }
    
    /* alloc mem block */
    pspseg = mem_alloc(max_memory, 1, &biggest);
    if (pspseg == 0) {
	if (biggest < min_memory ||
	    (pspseg = mem_alloc(biggest, 1, NULL)) == 0)
	    fatal("not enough memory: needed %d have %d\n",
		  min_memory, biggest);
	
	max_memory = biggest;
    }
    
    mem_change_owner(pspseg, pspseg);
    mem_change_owner(envseg, pspseg);
    
    /* create psp */
    newpsp = curpsp + 1;
    psp_s[newpsp] = pspseg;
    env_s[newpsp] = envseg;
    
    psp = (char *)MAKEPTR(pspseg, 0);
    memset(psp, 0, 256);
    
    psp[0] = 0xcd;
    psp[1] = 0x20;

    *(u_short *)&psp[2] = pspseg + max_memory;
    
    /*
     * this is supposed to be a long call to dos ... try to fake it
     */
    psp[5] = 0xcd;
    psp[6] = 0x99;
    psp[7] = 0xc3;
    
    *(u_short *)&psp[0x16] = psp_s[curpsp];
    psp[0x18] = 1;
    psp[0x19] = 1;
    psp[0x1a] = 1;
    psp[0x1b] = 0;
    psp[0x1c] = 2;
    memset(psp + 0x1d, 0xff, 15);
    
    *(u_short *)&psp[0x2c] = envseg;
    
    *(u_short *)&psp[0x32] = 20;
    *(u_long *)&psp[0x34] = MAKEVEC(pspseg, 0x18);
    *(u_long *)&psp[0x38] = 0xffffffff;
    
    psp[0x50] = 0xcd;
    psp[0x51] = 0x98;
    psp[0x52] = 0xc3;
    
    p = psp + 0x81;
    *p = 0;
    used = 0;
    for (i = 0; argv[i]; i++) {
	n = strlen(argv[i]);
	if (used + 1 + n > 0x7d)
	    break;
	*p++ = ' ';
	memcpy(p, argv[i], n);
	p += n;
	used += n;
    }

    psp[0x80] = strlen(psp + 0x81);
    psp[0x81 + psp[0x80]] = 0x0d;
    psp[0x82 + psp[0x80]] = 0;
    
    p = psp + 0x81;
    parse_filename(0x00, p, psp + 0x5c, &n);
    p += n;
    parse_filename(0x00, p, psp + 0x6c, &n);
    
    if (param[4]) {
	fcb = (char *)MAKEPTR(param[4], param[3]);
	memcpy(psp + 0x5c, fcb, 16);
    }
    if (param[6]) {
	fcb = (char *)MAKEPTR(param[6], param[5]);
	memcpy(psp + 0x6c, fcb, 16);
    }

#if 0
    printf("005c:");
    for (n = 0; n < 16; n++)
	printf(" %02x", psp[0x5c + n]);
    printf("\n");
    printf("006c:");
    for (n = 0; n < 16; n++)
	printf(" %02x", psp[0x6c + n]);
    printf("\n");
#endif

    disk_transfer_addr = MAKEVEC(pspseg, 0x80);
    
    start_segment = pspseg + 0x10;
    
    if (!exe_file) {
	load_com(fd, start_segment);

	init_cs = pspseg;
	init_ip = 0x100;
	init_ss = init_cs;
	init_sp = 0xfffe;
	init_ds = init_cs;
	init_es = init_cs;
    } else {
	load_exe(fd, start_segment, start_segment, &hdr, text_size);
	
	init_cs = hdr.init_cs + start_segment;
	init_ip = hdr.init_ip;
	init_ss = hdr.init_ss + start_segment;
	init_sp = hdr.init_sp;
	init_ds = pspseg;
	init_es = init_ds;
    }

    debug(D_EXEC, "cs:ip = %04x:%04x, ss:sp = %04x:%04x, "
	  "ds = %04x, es = %04x\n",
	  init_cs, init_ip, init_ss, init_sp, init_ds, init_es);
    
    if (run) {
	frames[newpsp] = *REGS;
	curpsp = newpsp;
	
	R_EFLAGS = 0x20202;
	R_CS = init_cs;
	R_IP = init_ip;
	R_SS = init_ss;
	R_SP = init_sp;
	R_DS = init_ds;
	R_ES = init_es;

	R_AX = R_BX = R_CX = R_DX = R_SI = R_DI = R_BP = 0;

    } else {
	param[7] = init_sp;
	param[8] = init_ss;
	param[9] = init_ip;
	param[10] = init_cs;
    }
}
Beispiel #2
0
void TriPatchObject::BuildPatch(TimeValue t,PatchMesh& amesh)
	{
	int nverts = 4;
	int nvecs = 16;
	float l, w;
	int tex;
	
	// Start the validity interval at forever and whittle it down.
	ivalid = FOREVER;
	pblock->GetValue( PB_LENGTH, t, l, ivalid );
	pblock->GetValue( PB_WIDTH, t, w, ivalid );
	pblock->GetValue( PB_TEXTURE, t, tex, ivalid );

	amesh.setNumVerts(nverts);
	amesh.setNumTVerts(tex ? nverts : 0);
	amesh.setNumVecs(nvecs);
	amesh.setNumPatches(2);
	amesh.setNumTVPatches(tex ? 2 : 0);

	Point3 v0 = Point3(-w, -l, 0.0f) / 2.0f;   
	Point3 v1 = v0 + Point3(w, 0.0f, 0.0f);
	Point3 v2 = v0 + Point3(w, l, 0.0f);
	Point3 v3 = v0 + Point3(0.0f, l, 0.0f);

	// Create the vertices.
	amesh.verts[0].flags = PVERT_COPLANAR;
	amesh.verts[1].flags = PVERT_COPLANAR;
	amesh.verts[2].flags = PVERT_COPLANAR;
	amesh.verts[3].flags = PVERT_COPLANAR;
	if(tex) {
		amesh.setTVert(0, UVVert(0,0,0));
		amesh.setTVert(1, UVVert(1,0,0));
		amesh.setTVert(2, UVVert(1,1,0));
		amesh.setTVert(3, UVVert(0,1,0));
		}
	amesh.setVert(0, v0);
	amesh.setVert(1, v1);
	amesh.setVert(2, v2);
	amesh.setVert(3, v3);

	// Create the vectors
	MAKEVEC(0, v0, v1);
	MAKEVEC(2, v1, v2);
	MAKEVEC(4, v2, v3);
	MAKEVEC(6, v3, v0);
	MAKEVEC(8, v3, v1);

	// Create patches.
	amesh.MakeTriPatch(0, 0, 0, 1, 1, 9, 8, 3, 6, 7, 10, 11, 12, 1);
	amesh.MakeTriPatch(1, 1, 2, 3, 2, 4, 5, 3, 8, 9, 13, 14, 15, 1);
	Patch &p1 = amesh.patches[0];
	Patch &p2 = amesh.patches[1];
	if(tex) {
		amesh.getTVPatch(0).setTVerts(0,1,3);
		amesh.getTVPatch(1).setTVerts(1,2,3);
		}

	// Finish up patch internal linkages (and bail out if it fails!)
	assert(amesh.buildLinkages());

	// Calculate the interior bezier points on the PatchMesh's patches
	amesh.computeInteriors();

	amesh.InvalidateGeomCache();

	// Tell the PatchMesh it just got changed
	amesh.InvalidateMesh();
	}
Beispiel #3
0
void
int33(regcontext_t *REGS)
{
    u_long vec = 0;
    u_short mask;
    int i;

    if (!nmice) {
	R_FLAGS |= PSL_C;	/* We don't support a mouse */
	return;
    }

    printf("Mouse: %02x\n", R_AX);
    switch (R_AX) {
    case 0x00:				/* Reset Mouse */
	printf("Installing mouse driver\n");
	R_AX = 0xffff;			/* Mouse installed */
	R_BX = 2;			/* Number of mouse buttons */
	memset(&mouse_status, 0, sizeof(mouse_status));
	mouse_status.installed = 1;
	mouse_status.hardcursor = 1;
	mouse_status.end = 16;
	mouse_status.hmickey = 8;
	mouse_status.vmickey = 16;
	mouse_status.doubling = 100;
	mouse_status.init = -1;
	mouse_status.range.w = 8 * 80;
	mouse_status.range.h = 16 * 25;
	break;

    case 0x01:	/* Display Mouse Cursor */
	if ((mouse_status.init += 1) == 0) {
	    mouse_status.show = 1;
	}
	break;

    case 0x02:	/* Hide Mouse Cursor */
	if (mouse_status.init == 0)
	    mouse_status.show = 0;
	mouse_status.init -= 1;
	break;

    case 0x03:	/* Get cursor position/button status */
	mouse_probe();
	R_CX = mouse_status.x;
	R_DX = mouse_status.y;
	R_BX = mouse_status.buttons;
	break;

    case 0x04:	/* Move mouse cursor */
	/* mouse_move(GET16(sc->sc_ecx), GET16(sc->sc_edx)); */
	break;

    case 0x05:	/* Determine number of times mouse button was active */
	i = R_BX & 3;
	if (i == 3)
	    i = 1;
	
	R_BX = mouse_status.downs[i];
	mouse_status.downs[i] = 0;
	R_AX = mouse_status.buttons;
	R_CX = mouse_status.x;		/* Not quite right */
	R_DX = mouse_status.y;		/* Not quite right */
	break;

    case 0x06:	/* Determine number of times mouse button was relsd */
	i = R_DX & 3;
	if (i == 3)
	    i = 1;
	
	R_BX = mouse_status.ups[i];
	mouse_status.ups[i] = 0;
	R_AX = mouse_status.buttons;
	R_CX = mouse_status.x;		/* Not quite right */
	R_DX = mouse_status.y;		/* Not quite right */
	break;
	
    case 0x07:	/* Set min/max horizontal cursor position */
	mouse_status.range.x = R_CX;
	mouse_status.range.w = R_DX - R_CX;
	break;
	
    case 0x08:	/* Set min/max vertical cursor position */
	mouse_status.range.y = R_CX;
	mouse_status.range.h = R_DX - R_CX;
	
    case 0x09:	/* Set graphics cursor block */
	/* BX,CX is hot spot, ES:DX is data. */
	break;
	
    case 0x0a:	/* Set Text Cursor */
	mouse_status.hardcursor = R_BX ? 1 : 0;
	mouse_status.start = R_CX;
	mouse_status.end = R_CX;	/* XXX is this right ? */
	break;

    case 0x0b:	/* Read Mouse Motion Counters */
	mouse_probe();
	R_CX = mouse_status.x - mouse_status.lastx;
	R_DX = mouse_status.y - mouse_status.lasty;
	break;

    case 0x0c:	/* Set event handler */
	mouse_status.mask = R_CX;
	mouse_status.handler = MAKEVEC(R_ES, R_DX);
	break;
    
    case 0x0d:	/* Enable light pen */
    case 0x0e:	/* Disable light pen */
	break;

    case 0x0f:	/* Set cursor speed */
	mouse_status.hmickey = R_CX;
	mouse_status.vmickey = R_DX;
	break;
    
    case 0x10:	/* Exclusive area */
	mouse_status.exclude.x = R_CX;
	mouse_status.exclude.y = R_DX;
	mouse_status.exclude.w = R_SI - R_CX;
	mouse_status.exclude.h = R_DI - R_DX;
	break;

    case 0x13:	/* Set maximum for mouse speed doubling */
	break;
    case 0x14:	/* Exchange event handlers */
	mask = mouse_status.mask;
	vec = mouse_status.handler;

	mouse_status.mask = R_CX;
	mouse_status.handler = MAKEVEC(R_ES, R_DX);
	R_CX = mask;
	PUTVEC(R_ES, R_DX, vec);
	break;

    case 0x15:	/* Determine mouse status buffer size */
	R_BX = sizeof(mouse_status);
	break;

    case 0x16:	/* Store mouse buffer */
	memcpy((char *)MAKEPTR(R_ES, R_DX), &mouse_status,
	       sizeof(mouse_status));
	break;

    case 0x17:	/* Restore mouse buffer */
	memcpy(&mouse_status, (char *)MAKEPTR(R_ES, R_DX),
	       sizeof(mouse_status));
	break;

    case 0x18:	/* Install alternate handler */
	mask = R_CX & 0xff;
	if ((R_CX & 0xe0) == 0x00 ||
	    mask == mouse_status.altmask[0] ||
	    mask == mouse_status.altmask[1] ||
	    mask == mouse_status.altmask[2] ||
	    (mouse_status.altmask[i = 0] &&
	     mouse_status.altmask[i = 1] &&
	     mouse_status.altmask[i = 2])) {
	    R_AX = 0xffff;
	    break;
	}
	mouse_status.altmask[i] = R_CX;
	mouse_status.althandler[i] = MAKEVEC(R_ES, R_DX);
	break;

    case 0x19:	/* Determine address of alternate event handler */
	mask = R_CX & 0xff;
	if (mask == mouse_status.altmask[0])
	    vec = mouse_status.althandler[0];
	else if (mask == mouse_status.altmask[1])
	    vec = mouse_status.althandler[1];
	else if (mask == mouse_status.altmask[2])
	    vec = mouse_status.althandler[2];
	else
	    R_CX = 0;
	PUTVEC(R_ES, R_DX, vec);
	break;

    case 0x1a:	/* set mouse sensitivity */
	mouse_status.hmickey = R_BX;
	mouse_status.vmickey = R_CX;
	mouse_status.doubling = R_DX;
	break;

    case 0x1b:	/* get mouse sensitivity */
	R_BX = mouse_status.hmickey;
	R_CX = mouse_status.vmickey;
	R_DX = mouse_status.doubling;
	break;

    case 0x1c:	/* set mouse hardware rate */
    case 0x1d:	/* set display page */
	break;

    case 0x1e:	/* get display page */
	R_BX = 0;	/* Always on display page 0 */
	break;

    case 0x1f:	/* Disable mouse driver */
	if (mouse_status.installed) {
	    PUTVEC(R_ES, R_DX, mouse_status.handler);
	    mouse_status.installed = 0;
	} else {
	    R_AX = 0xffff;
	}
	break;

    case 0x20:	/* Enable mouse driver */
	mouse_status.installed = 1;
	break;

    case 0x21:	/* Reset mouse driver */
	if (mouse_status.installed) {
	    mouse_status.show = 0;
	    mouse_status.handler = 0;
	    mouse_status.mask = 0;
	    mouse_status.cursor = 0;
	} else {
	    R_AX = 0xffff;
	}
	break;

    case 0x22:	/* Specified language for mouse messages */
	break;

    case 0x23:	/* Get language number */
	R_BX = 0;	/* Always return english */
	break;

    case 0x24:	/* Get mouse type */
	R_CX = 0x0400;		/* PS/2 style mouse */
	R_BX = 0x0600 + 24;	/* Version 6.24 */
	break;

    default:
	R_FLAGS |= PSL_C;
	break;
    }
}