Ejemplo n.º 1
0
/*-----------------------------------------------------------------------
 * Initialize GEM application:
 * open virtual workstation and get desktop extent.
 */
void
gem_init(void)
{
	WORD	i, wsin[11], hch;

	appl_init();
	if (!isAES4())
	{
		form_alert(1, "[3][ |Viewer can't run on |this TOS version.][ Quit ]");
		gem_exit(-1);
	}

	AES_Version = _AESglobal[0];
	MultiFlag   = _AESglobal[1];	/* -1 == MULTITOS, else single tasking */

	if( AES_Version >= 0x0410 )		/* CJG 06/24/93 */
	    IconFlag = SMALLER;
	else
	    IconFlag = 0;

	shel_grok(G_AP_TERM);
	wsid = aesid = graf_handle(&wchar, &hchar, &wbox, &hbox);
	wsin[0] = Getrez()+2;
	for (i = 1; i < 10; i++)
		wsin[i] = 1;
	wsin[i] = 2;

	v_opnvwk(wsin, &wsid, wsout);
	if (!wsid)
	{
		form_error(8); /* not enough memory */
		gem_exit(-1);
	}

/* Get default AES point size */
	vqt_attributes(aesid, &aes_t_attr.font);
	vst_font(wsid, 1);
	hch = def_pts = 0;
	while (hch < aes_t_attr.hchar)
		vst_point(wsid, ++def_pts, &i, &hch, &i, &i);

	wind_grect(0, WF_WORKXYWH, &desk);
}
Ejemplo n.º 2
0
init_colmap()
{

	int rez;
	int i;
	int *ptr;

	rez = Getrez();

	if( rez == 2 )
		ptr = CurHires;
	else if( rez == 1 )
		ptr = CurMedres;
	else
		ptr = CurLores;

	for( i=0; i<16; i++ ) {
		CurColMap[i] = ptr[i];
	}
}
Ejemplo n.º 3
0
*cdecl	cpx_init(XCPB *Xcpb)
{
	int i;				/* counter */
	
	xcpb = Xcpb;
	
	currez = Getrez();						/* find current resolution */
	open_vwork();
	close_vwork();
	numcol = work_out[13];					/* size of CLUT */
	
	if (!(*xcpb->getcookie)(_VDO, &curmode)) /* find current video mode */
		curmode = STVDO;	/* if no cookie, assume it's an ST */
	curmode >>= 16;			/* keep only upper word */	
		
	if (xcpb->booting) {		/* if just booted, read saved values */
	
		if (saved)				/* if user-preference saved */
			init(&usr_vals);	/* init to saved user-preference */
		return((CPXINFO *)TRUE);
		
	} else {					/* else run cpx */
	
		appl_init();
		AES_Version = _GemParBlk.global[0];
		
		bpg = calc_bpg(work_out[39]);	/* calculate bits per gun */
		val_max = (1 << bpg) - 1;		/* init RGB sliders max value */
		
		if(!xcpb->SkipRshFix)			/* fix up the resource */
			(*xcpb->rsh_fix)(NUM_OBS, NUM_FRSTR, NUM_FRIMG, NUM_TREE,
						rs_object, rs_tedinfo, rs_strings, rs_iconblk,
						rs_bitblk, rs_frstr, rs_frimg, rs_trindex,
						rs_imdope);
	
		ActiveTree(rs_object);			/* tree -> color panel */
	
		/* set up color boxes on screen */
		switch (numcol) {
			case 2:							/* can show 2 colors */
				headbox = curbox = DUO0;
				col_page = 1;				/* page by 1 color */
				ShowObj(DUOBOXES);			/* show 2 boxes */
				break;
			
			case 4:							/* can show 4 colors */
				headbox = curbox = QUARTRO0;
				col_page = 1;				/* page by 1 color */
				ShowObj(QTBOXES);			/* show 4 boxes */
				break;
		
			default:						/* can show >= 16 colors */
				headbox = curbox = BOX0;
				ShowObj(ALLBOXES);			/* show 16 boxes */
				if (numcol == 16)			/* if 16 colors */
					col_page = 2;			/* page by 2 colors */
				else						/* if > 16 colors */
					col_page = MAX_COL_SHOWN; /* page by max displayed */
				break;
		}
		
		if (currez == STHI) {				/* if in ST High rez */
			ShowObj(INVRSVDO);				/* show Invert button */
			flip(0, &curinv);				/* init and save current */
			oldinv = curinv;				/*   inverse state       */
			if (!(curinv & NOT_FLIPPED))	
				Select(INVRSVDO);
		}
		
		if((int)curmode == TTVDO) {
			switch(currez) {			/* what's the current rez? */
				case TTHI:				/* if TT high */
					HideObj(COLSAVE);	/* nothing to be saved */
					HideObj(COLCNCEL);	/* nothing to be cancelled */
					HideObj(COLRLOAD);	/* nothing to be reload */
					break;
					
				default:				/* if ST Low, ST Med or TT Med */
					ShowObj(BNKBOX);	/* allow bank switching */
					numbnk = NUM_BNK;	/* there are NUM_BNKs */
					oldbnk = curbnk		/* save bank number */
						= EsetBank(-1);
					update_slid(HORIZONTAL, BNKBASE, BNKSLID, curbnk, 
							BNK_MIN, BNK_MAX, 0);
				
				case STHI:				/* if ST high or TT Low */
				case TTLOW:
					/* init and save hypermono mode */
					if ((oldgray = curgray = EsetGray(-1)) != 0) {
						HideObj(SETGRAY);
						ShowObj(SETCOL);
					} else {
						HideObj(SETCOL);
						ShowObj(SETGRAY);
					}
					break;
			}
		}
		
		headcol = curcol = 0;		/* init color on screen */
		
		if (!bpg) {					/* if monochrome */
			HideObj(RGBSLID);		/* don't need color controls */
		} else {					/* if color */
			totcol = numbnk * numcol;	/* number of color dealing with */
			
			/* no bank has been set up or touched yet */
			for (i = BNK_MIN; i < numbnk; i++)
				setup_bnk[i] = touch_bnk[i] = CLEAN;
				
			visit_bnk(0);	/* init data structures of current bank */
			curscrn[R] = curscrn[G] = curscrn[B] = -1;
			update_rgb(0);	/* init RGBs on screen */
		}
		
		/* set up color # slider */
		col_max = numcol - 1;			
		(*xcpb->Sl_size)(tree, COLBASE, COLSLID, numcol, 1, 
			VERTICAL, 16);
		update_slid(VERTICAL, COLBASE, COLSLID, curcol, col_max, 
			col_min, 0);
		
		/* Initialize the CPXINFO structure */           
		cpxinfo.cpx_call = colpnl;
		cpxinfo.cpx_draw = NULL;
		cpxinfo.cpx_wmove = NULL;
		cpxinfo.cpx_timer = NULL;
		cpxinfo.cpx_key = NULL;
		cpxinfo.cpx_button = NULL;
		cpxinfo.cpx_m1 = NULL;
		cpxinfo.cpx_m2 = NULL;
		cpxinfo.cpx_hook = NULL;
		cpxinfo.cpx_close = NULL;
      
		/* Return the pointer to the CPXINFO structure to XCONTROL */
		return(&cpxinfo);
		
	}
}
Ejemplo n.º 4
0
int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
    int i;
    short work_in[12], work_out[272], dummy;

    /* Open AES (Application Environment Services) */
    if (appl_init() == -1) {
        fprintf(stderr,"Can not open AES\n");
        return 1;
    }

    /* Read version and features */
    GEM_version = aes_params.global[0];
    if (GEM_version >= 0x0400) {
        short ap_gout[4];

        GEM_wfeatures=0;
        if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3])==0) {
            GEM_wfeatures=ap_gout[0];
        }
    }

    /* Ask VDI physical workstation handle opened by AES */
    VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
    if (VDI_handle<1) {
        fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle);
        return 1;
    }

    /* Open virtual VDI workstation */
    work_in[0]=Getrez()+2;
    for(i = 1; i < 10; i++)
        work_in[i] = 1;
    work_in[10] = 2;

    v_opnvwk(work_in, &VDI_handle, work_out);
    if (VDI_handle == 0) {
        fprintf(stderr,"Can not open VDI virtual workstation\n");
        return 1;
    }

    /* Read fullscreen size */
    VDI_w = work_out[0] + 1;
    VDI_h = work_out[1] + 1;

    /* Read desktop size and position */
    if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) {
        fprintf(stderr,"Can not read desktop properties\n");
        return 1;
    }

    /* Read bit depth */
    vq_extnd(VDI_handle, 1, work_out);
    VDI_bpp = work_out[4];
    VDI_oldnumcolors=0;

    switch(VDI_bpp) {
    case 8:
        VDI_pixelsize=1;
        break;
    case 15:
    case 16:
        VDI_pixelsize=2;
        break;
    case 24:
        VDI_pixelsize=3;
        break;
    case 32:
        VDI_pixelsize=4;
        break;
    default:
        fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp);
        return 1;
    }

    /* Setup hardware -> VDI palette mapping */
    for(i = 16; i < 255; i++) {
        vdi_index[i] = i;
    }
    vdi_index[255] = 1;

    /* Save current palette */
    if (VDI_bpp>8) {
        VDI_oldnumcolors=1<<8;
    } else {
        VDI_oldnumcolors=1<<VDI_bpp;
    }

    for(i = 0; i < VDI_oldnumcolors; i++) {
        short rgb[3];

        vq_color(VDI_handle, i, 0, rgb);

        VDI_oldpalette[i][0] = rgb[0];
        VDI_oldpalette[i][1] = rgb[1];
        VDI_oldpalette[i][2] = rgb[2];
    }

    /* Setup screen info */
    GEM_title_name = empty_name;
    GEM_icon_name = empty_name;

    GEM_handle = -1;
    GEM_locked = SDL_FALSE;
    GEM_win_fulled = SDL_FALSE;

    VDI_screen = NULL;
    VDI_ReadExtInfo(this, work_out);
    if (VDI_screen == NULL) {
        VDI_pitch = VDI_w * VDI_pixelsize;
        VDI_format = VDI_FORMAT_UNKNOWN;
        VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
    }

    /* Setup destination mfdb */
    VDI_dst_mfdb.fd_addr = NULL;

    /* Update hardware info */
    this->info.hw_available = 0;
    this->info.video_mem = 0;

    /*	TC, screen : no shadow (direct)
     *  8P, screen: no shadow (direct)
     *  8I, screen: shadow, c2p (shadow -> c2p)
     *  TC, no screen: shadow (vro_cpyfm)
     *  8P, no screen: shadow (vro_cpyfm)
     *  8I/U, no screen: shadow, shadow_c2p, c2p (shadow -> c2p -> vro_cpyfm)
     */

    /* Determine the screen depth */
    /* we change this during the SDL_SetVideoMode implementation... */
    vformat->BitsPerPixel = VDI_bpp;

    /* Set mouse cursor to arrow */
    graf_mouse(ARROW, NULL);

    /* Init chunky to planar routine */
    Atari_C2pInit = Atari_C2pInit8;
    if (atari_cpu060_avail) {
        Atari_C2pConvert = Atari_C2pConvert8_060;
    } else {
        Atari_C2pConvert = Atari_C2pConvert8;
    }
    Atari_C2pInit();

    /* We're done! */
    return(0);
}
Ejemplo n.º 5
0
*cdecl cpx_init( XCPB *Xcpb )
{
    OBJECT *tree;
    int    i;

    appl_init();

    currez = Getrez();				/* find current resolution */
    xcpb = Xcpb;
    vhandle = xcpb->handle;
    if( xcpb->booting )
    {
      /* Read in the default settings and set the hardware */
      cur_value = save_vars;
      Init_Speed();
      Init_Block2();
      Set_Data();
      return( ( CPXINFO *)TRUE );  
    }
    else
    {

       open_vwork();
       close_vwork();
       numcol = work_out[13];			/* size of CLUT */
       
       AES_Version = _GemParBlk.global[0];
        
       if( !xcpb->SkipRshFix )
          (*xcpb->rsh_fix)( NUM_OBS, NUM_FRSTR, NUM_FRIMG, NUM_TREE,
                           rs_object, rs_tedinfo, rs_strings, rs_iconblk,
                           rs_bitblk, rs_frstr, rs_frimg, rs_trindex,
                           rs_imdope );
       /*
        * Get the current settings of the hardware and store them
        * in the current GEN structure
        */
       cur_value = save_vars;
       Init_Speed();
       Init_Block2();
       Get_Data();
       push_data();
       cpxinfo.cpx_call   = cpx_call;
       cpxinfo.cpx_draw   = NULL;
       cpxinfo.cpx_wmove  = NULL;
       cpxinfo.cpx_timer  = NULL;
       cpxinfo.cpx_key    = NULL;
       cpxinfo.cpx_button = NULL;
       cpxinfo.cpx_m1 	  = NULL;
       cpxinfo.cpx_m2	  = NULL;
       cpxinfo.cpx_hook	  = NULL;
       cpxinfo.cpx_close  = NULL;

       if( !xcpb->SkipRshFix )
       {
        if(( AES_Version >= 0x0330 )
	    && ( numcol > LWHITE ) )
        {
         tree = ( OBJECT *)rs_trindex[ GENERAL ];
         MakeActivator( GENERAL, GSAVE );
         MakeActivator( GENERAL, GOK );
         MakeActivator( GENERAL, GCANCEL );
	 ObH( GSAVE )    = 16;
	 ObH( GOK )      = 16;
	 ObH( GCANCEL )  = 16;
	 ObIndex( B4 ) &= 0xff00ffffL;

	 ObX( GSAVE ) += 1;
	 ObY( GSAVE ) += 2;
	 ObW( GSAVE ) -= 2;
	 ObH( GSAVE ) -= 3;

	 ObX( GOK ) += 1;
	 ObY( GOK ) += 2;
	 ObW( GOK ) -= 2;
	 ObH( GOK ) -= 3;

	 ObX( GCANCEL ) += 1;
	 ObY( GCANCEL ) += 2;
	 ObW( GCANCEL ) -= 2;
	 ObH( GCANCEL ) -= 3;

	 ObX( LRESP ) += 2;
	 ObX( RRESP ) -= 2;
	 for( i = RESPBASE; i <= LRESP; i++ )
	 {
	    MakeActivator( GENERAL, i );
	    ObH( i ) = 16;
	    if( ( ObType( i ) & 0x00ff ) == G_BOXTEXT )
	      TedColor( i ) = ( TedColor( i ) & 0xff70 ) | LWHITE | 0x70;
	    
	    if( ( ObType( i ) & 0x00ff ) == G_BOXCHAR )
	      ObIndex( i ) = ( ObIndex( i ) & 0xffffff70 ) | LWHITE | 0x70;

	   if( i == RESPBASE )	   
	   {
	     ObX( i ) = ObX( LRESP ) + ObW( LRESP ) + 5;
	     ObW( i ) = ( ObX( RRESP ) - 5 ) - ObX( i );
	   }
	      
	 }   
	 ObIndex( B6 ) &= 0xff00ffffL;
	 ObIndex( B7 ) &= 0xffffff70L;


	 ObX( LREPEAT ) += 2;
	 ObX( RREPEAT ) -= 2;	 
	 for( i = LREPEAT; i <= KREPEAT; i++ )
	 {
	    MakeActivator( GENERAL, i );
	    ObH( i ) = 16;
	    if( ( ObType( i ) & 0x00ff ) == G_BOXTEXT )
	      TedColor( i ) = ( TedColor( i ) & 0xff70 ) | LWHITE | 0x70;

	    if( ( ObType( i ) & 0x00ff ) == G_BOXCHAR )
	      ObIndex( i ) = ( ObIndex( i ) & 0xffffff70 ) | LWHITE | 0x70;

	    if( i == REPTBASE )	   
	    {
	      ObX( i ) = ObX( LREPEAT ) + ObW( LREPEAT ) + 5;
	      ObW( i ) = ( ObX( RREPEAT ) - 5 ) - ObX( i );
	    }

	 }   
	 ObIndex( B8 ) &= 0xff00ffffL;
	 ObIndex( B9 ) &= 0xffffff70L;
	 
	 ObIndex( B0 ) &= 0xffffff70L;
	 MakeActivator( GENERAL, STATUS );
	 ObX( STATUS ) += 1;
	 ObY( STATUS ) += 2;
	 ObW( STATUS ) -= 2;
	 ObH( STATUS ) -= 4;


	 MakeActivator( GENERAL, DOUBLE );
	 ObX( DOUBLE ) += 1;
	 ObY( DOUBLE ) += 1;
	 ObW( DOUBLE ) -= 2;
	 ObH( DOUBLE ) -= 2;
         TedColor( DOUBLE ) = ( TedColor( DOUBLE ) & 0xFF70 ) | LWHITE | 0x70;
	 ObIndex( B5 ) &= 0xff00ff70L;	 	 

	 ObIndex( B1 ) = ( ObIndex( B1 ) & 0xffffff70L ) | LWHITE | 0x70;
	 ObIndex( B2 ) = ( ObIndex( B1 ) & 0xffffff70L ) | LWHITE | 0x70;
	 ObIndex( B3 ) &= 0xffffff70L;

         TedColor( BLK1TXT ) = ( TedColor( BLK1TXT ) & 0xFF70 );
	 ObIndex( BLK1 ) &= 0xffffff70L;
	 tree[(BLK1TXT)].ob_spec.tedinfo->te_thickness = 0;
	 
         TedColor( BLK2TXT ) = ( TedColor( BLK2TXT ) & 0xFF70 );
	 ObIndex( BLK2 ) &= 0xffffff70L;
	 tree[(BLK2TXT)].ob_spec.tedinfo->te_thickness = 0;
	 
         tree = ( OBJECT *)rs_trindex[ PARTZ ];
         MakeActivator( PARTZ, STATOK );
        }
       } /*        if( !xcpb->SkipRshFix )*/

       return( &cpxinfo );
    }
}
Ejemplo n.º 6
0
int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
	int i, menubar_size;
	short work_in[12], work_out[272], dummy;

	/* Open AES (Application Environment Services) */
	if (appl_init() == -1) {
		fprintf(stderr,"Can not open AES\n");
		return 1;
	}

	/* Read version and features */
	GEM_version = aes_global[0];
	if (GEM_version >= 0x0410) {
		short ap_gout[4], errorcode;
		
		GEM_wfeatures=0;
		errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]);

		if (errorcode==0) {
			GEM_wfeatures=ap_gout[0];			
		}
	}	

	/* Ask VDI physical workstation handle opened by AES */
	VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
	if (VDI_handle<1) {
		fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle);
		return 1;
	}

	/* Open virtual VDI workstation */
	work_in[0]=Getrez()+2;
	for(i = 1; i < 10; i++)
		work_in[i] = 1;
	work_in[10] = 2;

	v_opnvwk(work_in, &VDI_handle, work_out);
	if (VDI_handle == 0) {
		fprintf(stderr,"Can not open VDI virtual workstation\n");
		return 1;
	}

	/* Read fullscreen size */
	VDI_w = work_out[0] + 1;
	VDI_h = work_out[1] + 1;

	/* Read desktop size and position */
	if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) {
		fprintf(stderr,"Can not read desktop properties\n");
		return 1;
	}

	/* Read bit depth */
	vq_extnd(VDI_handle, 1, work_out);
	VDI_bpp = work_out[4];
	VDI_oldnumcolors=0;

	switch(VDI_bpp) {
		case 8:
			VDI_pixelsize=1;
			break;
		case 15:
		case 16:
			VDI_pixelsize=2;
			break;
		case 24:
			VDI_pixelsize=3;
			break;
		case 32:
			VDI_pixelsize=4;
			break;
		default:
			fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp);
			return 1;
	}

	/* Setup hardware -> VDI palette mapping */
	for(i = 16; i < 255; i++) {
		vdi_index[i] = i;
	}
	vdi_index[255] = 1;

	/* Save current palette */
	if (VDI_bpp>8) {
		VDI_oldnumcolors=1<<8;
	} else {
		VDI_oldnumcolors=1<<VDI_bpp;
	}
	
	for(i = 0; i < VDI_oldnumcolors; i++) {
		short rgb[3];

		vq_color(VDI_handle, i, 0, rgb);

		VDI_oldpalette[i][0] = rgb[0];
		VDI_oldpalette[i][1] = rgb[1];
		VDI_oldpalette[i][2] = rgb[2];
	}
	VDI_setpalette = GEM_SetNewPalette;
	SDL_memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette));

	/* Setup screen info */
	GEM_title_name = empty_name;
	GEM_icon_name = empty_name;

	GEM_handle = -1;
	GEM_locked = SDL_FALSE;
	GEM_win_fulled = SDL_FALSE;
	GEM_fullscreen = SDL_FALSE;
	GEM_lock_redraw = SDL_TRUE;	/* Prevent redraw till buffers are setup */

	VDI_screen = NULL;
	VDI_pitch = VDI_w * VDI_pixelsize;
	VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
	VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
	VDI_ReadExtInfo(this, work_out);

#ifdef DEBUG_VIDEO_GEM
	printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, VDI_pitch);
	printf("sdl:video:gem: format=%d\n", VDI_format);
	printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
		VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask
	);
#endif

	/* Setup destination mfdb */
	VDI_dst_mfdb.fd_addr = NULL;

	/* Determine the current screen size */
	this->info.current_w = VDI_w;
	this->info.current_h = VDI_h;

	/* Determine the screen depth */
	/* we change this during the SDL_SetVideoMode implementation... */
	vformat->BitsPerPixel = VDI_bpp;

	/* Set mouse cursor to arrow */
	graf_mouse(ARROW, NULL);
	GEM_cursor = NULL;

	/* Init chunky to planar routine */
	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;

	/* Setup VDI fill functions */
	vsf_color(VDI_handle,0);
	vsf_interior(VDI_handle,1);
	vsf_perimeter(VDI_handle,0);

	/* Menu bar save buffer */
	menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize;
	GEM_menubar=Atari_SysMalloc(menubar_size,MX_PREFTTRAM);

	/* Fill video modes list */
	SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect));
	SDL_modelist[0]->x = 0;
	SDL_modelist[0]->y = 0;
	SDL_modelist[0]->w = VDI_w;
	SDL_modelist[0]->h = VDI_h;

	SDL_modelist[1] = NULL;

#if SDL_VIDEO_OPENGL
	SDL_AtariGL_InitPointers(this);
#endif

	this->info.wm_available = 1;

	/* We're done! */
	return(0);
}
Ejemplo n.º 7
0
/* cpx_init()
 * ======================================================================
 * cpx_init() is where a CPX is first initialized.
 * There are TWO parts.
 *
 * PART ONE: cpx_init() is called when the CPX is first 'booted'. This is
 *	     where the CPX should read in its defaults and then set the
 *	     hardware based on those defaults.  
 *
 * PART TWO: The other time cpx_init() is called is when the CPX is being
 *	     executed.  This is where the resource is fixed up and current
 *	     cpx variables are updated from the hardware.  In addition,
 *	     this is where the CPXINFO structure should be filled out.
 *
 * IN:  XCPB	*Xcpb:	Pointer to the XControl Parameter Block
 * OUT: CPXINFO  *ptr:	Pointer to the CP Information Structure
 */			
CPXINFO
*cpx_init( XCPB *Xcpb )
{
    appl_init();

    xcpb = Xcpb;

    currez = Getrez();				/* find current resolution */
    open_vwork();
    close_vwork();
    numcol = work_out[13];			/* size of CLUT */
    
    if( xcpb->booting )
    {
	if( saved )		/* if user-preference saved */
  	   init( &usr_vals );	/* init to saved user-preference */
	else
	   init( &def_vals );	/* init to default values */

        return( ( CPXINFO *)TRUE );  
    }
    else
    {    
      appl_init();
      AES_Version = _AESglobal[0];

      if( !xcpb->SkipRshFix )
      {
           (*xcpb->rsh_fix)( NUM_OBS, NUM_FRSTR, NUM_FRIMG, NUM_TREE,
                            rs_object, rs_tedinfo, rs_strings, rs_iconblk,
                            rs_bitblk, rs_frstr, rs_frimg, rs_trindex,
                            rs_imdope );
      }
 
      ad_tree   = (OBJECT *)rs_trindex[ COLOR ];
      ad_slide1 = ( OBJECT *)rs_trindex[ SLIDE1 ];
      ad_slide2 = ( OBJECT *)rs_trindex[ SLIDE2 ];

      ActiveTree( ad_slide1 );
      ObX( ROOT ) = ObY( ROOT ) = 0;
      ObW( ROOT ) = work_out[0] - 1;
      ObH( ROOT ) = work_out[1] - 1;
      ObW( EXIT1 ) = ObH( EXIT1 ) = 0;

      ActiveTree( ad_slide2 );
      ObX( ROOT ) = ObY( ROOT ) = 0;
      ObW( ROOT ) = work_out[0] - 1;
      ObH( ROOT ) = work_out[1] - 1;
      ObW( EXIT2 ) = ObH( EXIT2 ) = 0;
  

      ActiveTree( ad_tree );
      HideObj( BASE2 );
      HideObj( BASE4 );
      HideObj( BASE16 );

      /* set up color boxes on screen */
      switch( numcol )
      {
        case 2:   headbox = curbox = TWO01;
        	  col_page = 1;
        	  ShowObj( BASE2 );
        	  break;
        	  
        case 4:	  headbox = curbox = FOUR01;
        	  col_page = 1;
        	  ShowObj( BASE4 );
        	  break;
        	  
        default:  headbox = curbox = BOX0;
		  if (numcol == 16)			/* if 16 colors */
		      col_page = 2;			/* page by 2 colors */
		  else					/* if > 16 colors */
		      col_page = MAX_COL_SHOWN; /* page by max displayed */
        	  ShowObj( BASE16 );
        	  break;
      }


      /* set up color # slider */
      headcol = curcol = 0;		/* init color on screen */
      setup_bnk = touch_bnk = CLEAN;
      visit_bnk();	/* init data structures of current bank */

      curscrn[R] = curscrn[G] = curscrn[B] = -1;
      update_rgb(0);	/* init RGBs on screen */
      col_max = numcol - 1;			
      (*xcpb->Sl_size)( tree, CBASE, CSLIDE, numcol, 1, VERTICAL, 16 );
      update_slid( CBASE, CSLIDE, curcol, col_max, col_min, 0 );

           
      /* Initialize the CPXINFO structure */           
      cpxinfo.cpx_call   = cpx_call;
      cpxinfo.cpx_draw   = NULL;
      cpxinfo.cpx_wmove  = NULL;
      cpxinfo.cpx_timer  = NULL;
      cpxinfo.cpx_key    = NULL;
      cpxinfo.cpx_button = NULL;
      cpxinfo.cpx_m1 	 = NULL;
      cpxinfo.cpx_m2	 = NULL;
      cpxinfo.cpx_hook   = NULL;
      cpxinfo.cpx_close  = NULL;

      /* Convert to 3D if possible - ONLY if AES 0x0400 or Greater!
       * AND if # of pens is greater than LWHITE
       */
      if( !xcpb->SkipRshFix )
      {
        if(( AES_Version >= 0x0330 )
	  && ( numcol > LWHITE ) )
        {
          Do3D();
        }
      }
      /* Return the pointer to the CPXINFO structure to XCONTROL */
      return( &cpxinfo );
    }
}
Ejemplo n.º 8
0
void
main( int argc, char *argv[], char *envp[] )
{
	int 	i;
/* 	-----	evnt_multi return parameters */
	int		event, msg[8], key, nclicks;
	MRETS	mrets;
	int  	rez;
/*
 * Initialize global arguments
 */
	if( (nargs = argc) != 1)
		args = argv;
	env = envp;

/*
 * See if we were run from the AUTO folder...
 */
	if( (gl_apid = appl_init()) == -1 ) {
		Cconws("\r\nError initializing GEM, hit a key...");
		Cconin();
		exit( gl_apid );
	}
	rez = Getrez() + 2;
	if(( rez != 2 ) && ( rez != 6 ) )
	{
	   /* Ensure that we run ONLY in ST LOW or TT MED - 640x480 16 colors */
	   form_alert( 1, "[3][ | This program runs in| ST LOW or TT MED Only][ OK ]" );
	   appl_exit();
	   exit( -1 );
	}
/*
 * Set up work_in to initialize VDI functions to useful values,
 * Get the physical workstation handle from the AES, then
 * open a virtual workstation and get our AES work area's extent.
 */
	work_in[0] = Getrez()+2; /* let's not gag GDOS */
	for( i = 1; i < 10; work_in[i++] = 1 )
	;
	work_in[10] = 2; /* raster coordinates */
	vhandle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );
	v_opnvwk( work_in, &vhandle, work_out );
	xres = work_out[0];
	yres = work_out[1];

/*
 * Call initialization hooks
 */
	Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk );
	if( !rsrc_init() ) {
		form_alert( 1, "[3][ RSC ERROR ][ OK ]" );
		v_clsvwk( vhandle );
		appl_exit();
		exit( -1 );
	}

	wind_init();
	evnt_init();

/*
 * Main event loop
 */
	do {

		event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate,
							&ev_m1, &ev_m2, ( WORD *)msg, ev_time,
							&mrets, ( WORD *)&key, ( WORD *)&nclicks );
		wind_update( BEG_UPDATE );
	/*
	 * call pre-event-processing hook
	 */
		if( evnt_hook( event, msg, &mrets, &key, &nclicks ) )
			continue;

	/* Dispatch events.
	 * It is possible to get more than one event at a time, so if the
	 * order of event handling is important to you, change the order
	 * in which they're handled here.
	 */
		if( event & MU_TIMER )
			do_timer( &event );

		if( event & MU_KEYBD )
			do_key( mrets.kstate, key, &event );

		if( event & MU_BUTTON )
			do_button( &mrets, nclicks, &event );

		if( event & MU_M1 )
			do_m1( &mrets, &event );

		if( event & MU_M2 )
			do_m2( &mrets, &event );

		if( event & MU_MESAG )
			switch( msg[0] ) {

				case MN_SELECTED:
					do_menu( msg, &event );
				break;

				case WM_REDRAW:
				case WM_TOPPED:
				case WM_CLOSED:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				case WM_SIZED:
				case WM_MOVED:
				case WM_NEWTOP:
					do_windows( msg, &event );
				break;

				case AC_OPEN:
					acc_open( msg );
				break;

				case AC_CLOSE:
					acc_close( msg );
				break;

				default:
					msg_hook( msg, &event );
			} /* switch */
		/* MU_MESAG */

		wind_update( END_UPDATE );

	/*
	 * Event handling routines zero out the event variable
	 * to exit the application.
	 */
	} while( event );

	gem_exit( 0 );
}
Ejemplo n.º 9
0
int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
	int i, menubar_size;
	short work_in[12], work_out[272], dummy;

	
	if (appl_init() == -1) {
		fprintf(stderr,"Can not open AES\n");
		return 1;
	}

	
	GEM_version = aes_global[0];
	if (GEM_version >= 0x0410) {
		short ap_gout[4], errorcode;
		
		GEM_wfeatures=0;
		errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]);

		if (errorcode==0) {
			GEM_wfeatures=ap_gout[0];			
		}
	}	

	
	VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
	if (VDI_handle<1) {
		fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle);
		return 1;
	}

	
	work_in[0]=Getrez()+2;
	for(i = 1; i < 10; i++)
		work_in[i] = 1;
	work_in[10] = 2;

	v_opnvwk(work_in, &VDI_handle, work_out);
	if (VDI_handle == 0) {
		fprintf(stderr,"Can not open VDI virtual workstation\n");
		return 1;
	}

	
	VDI_w = work_out[0] + 1;
	VDI_h = work_out[1] + 1;

	
	if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) {
		fprintf(stderr,"Can not read desktop properties\n");
		return 1;
	}

	
	vq_extnd(VDI_handle, 1, work_out);
	VDI_bpp = work_out[4];
	VDI_oldnumcolors=0;

	switch(VDI_bpp) {
		case 8:
			VDI_pixelsize=1;
			break;
		case 15:
		case 16:
			VDI_pixelsize=2;
			break;
		case 24:
			VDI_pixelsize=3;
			break;
		case 32:
			VDI_pixelsize=4;
			break;
		default:
			fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp);
			return 1;
	}

	
	for(i = 16; i < 255; i++) {
		vdi_index[i] = i;
	}
	vdi_index[255] = 1;

	
	if (VDI_bpp>8) {
		VDI_oldnumcolors=1<<8;
	} else {
		VDI_oldnumcolors=1<<VDI_bpp;
	}
	
	for(i = 0; i < VDI_oldnumcolors; i++) {
		short rgb[3];

		vq_color(VDI_handle, i, 0, rgb);

		VDI_oldpalette[i][0] = rgb[0];
		VDI_oldpalette[i][1] = rgb[1];
		VDI_oldpalette[i][2] = rgb[2];
	}
	VDI_setpalette = GEM_SetNewPalette;
	SDL_memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette));

	
	GEM_title_name = empty_name;
	GEM_icon_name = empty_name;

	GEM_handle = -1;
	GEM_locked = SDL_FALSE;
	GEM_win_fulled = SDL_FALSE;
	GEM_fullscreen = SDL_FALSE;
	GEM_lock_redraw = SDL_TRUE;	

	VDI_screen = NULL;
	VDI_pitch = VDI_w * VDI_pixelsize;
	VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
	VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
	VDI_ReadExtInfo(this, work_out);

#ifdef DEBUG_VIDEO_GEM
	printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, VDI_pitch);
	printf("sdl:video:gem: format=%d\n", VDI_format);
	printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
		VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask
	);
#endif

	
	VDI_dst_mfdb.fd_addr = NULL;

	
	this->info.current_w = VDI_w;
	this->info.current_h = VDI_h;

	
	
	vformat->BitsPerPixel = VDI_bpp;

	
	graf_mouse(ARROW, NULL);
	GEM_cursor = NULL;

	
	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;

	
	vsf_color(VDI_handle,0);
	vsf_interior(VDI_handle,1);
	vsf_perimeter(VDI_handle,0);

	
	menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize;
	GEM_menubar=Atari_SysMalloc(menubar_size,MX_PREFTTRAM);

	
	SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect));
	SDL_modelist[0]->x = 0;
	SDL_modelist[0]->y = 0;
	SDL_modelist[0]->w = VDI_w;
	SDL_modelist[0]->h = VDI_h;

	SDL_modelist[1] = NULL;

#if SDL_VIDEO_OPENGL
	SDL_AtariGL_InitPointers(this);
#endif

	this->info.wm_available = 1;

	
	return(0);
}
Ejemplo n.º 10
0
GemInit()
{
	int	work_in[11];
	int	i;
	int 	dev_id;
	int work_out[57];


	appl_init();

	if( gl_apid == -1 ) 
		return(4);

	/* Make Alice compatible with the fine Atari GDOS */
        dev_id = Getrez() + 2;

	gem_handle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );
	vdi_handle = gem_handle;

	/*
	 * Open the Virtual Workstation
	 */
	for( i=1; i<10; i++ ) work_in[i] = 1;
	work_in[0] = dev_id;
	work_in[10] = 2;		/* Raster coords */

	v_opnvwk( work_in, &vdi_handle, work_out );

	scr_area.g_w = work_out[0] + 1;
	scr_area.g_h = work_out[1] + 1;
	scr_area.g_x = 0;
	scr_area.g_y = 0;

	if( (scr_area.g_w / gl_wchar) < 70 )
		LoRes = TRUE;

#ifdef EMBEDDED_RCS
	rsc_fix();
#else

	if( !rsrc_load( "ALICE.RSC" ) ) {
		form_alert( 1, LDS( 375, 
		"[3][Fatal Error !|ALICE.RSC must be|in current directory][ Abort ]"));
		v_clsvwk( vdi_handle );
		appl_exit();
		exit( 1 );
	}

#endif EMBEDDED_RCS

#ifndef SAI
	/*
	 * Set up the menu bar
	 */

	rsrc_gaddr( R_TREE, MENU, &gl_menu );

	if( LoRes ) {
		ShortenMenu( gl_menu );
		FixBar( gl_menu );
	}

	menu_bar( gl_menu, TRUE );

#endif SAI

	/*
	 * Set the mouse to an arrow, and end the update
	 */
	graf_mouse( ARROW, 0x0L );

	resetVDI();

}
Ejemplo n.º 11
0
/*
 *  Save the current state of all the desktop options/icons/windows
 *  etc to memory and, optionally, to a file called EMUDESK.INF
 */
void app_save(WORD todisk)
{
    WORD i;
    WORD env1, env2, mode, env5;
    BYTE type;
    BYTE *pcurr, *ptmp;
    ANODE *pa;
    WSAVE *pws;

    memset(gl_afile, 0, SIZE_AFILE);
    pcurr = gl_afile;

    /* save revision level */
    pcurr += sprintf(pcurr,"#R %02X\r\n",INF_REV_LEVEL);

    /* save autorun (if any) */
    for (pa = G.g_ahead; pa; pa = pa->a_next)
        if (pa->a_flags & AF_AUTORUN)
            pcurr += sprintf(pcurr,"#Z %02X %s@\r\n",pa->a_flags&AF_ISCRYS,pa->a_pappl);

    /* save environment */
    env1 = (G.g_cnxsave.cs_view) ? INF_E1_VIEWTEXT : 0x00;
    env1 |= ((G.g_cnxsave.cs_sort) << 5) & INF_E1_SORTMASK;
    env1 |= (G.g_cnxsave.cs_confdel) ? INF_E1_CONFDEL : 0x00;
    env1 |= (G.g_cnxsave.cs_confcpy) ? INF_E1_CONFCPY : 0x00;
    env1 |= G.g_cnxsave.cs_dblclick & INF_E1_DCMASK;
    env2 = (G.g_cnxsave.cs_confovwr) ? 0x00 : INF_E2_ALLOWOVW;
    env2 |= (G.g_cnxsave.cs_mnuclick) ? INF_E2_MNUCLICK : 0x00;
    switch(G.g_cnxsave.cs_datefmt)
    {
    case DATEFORM_IDT:
        env2 |= INF_E2_IDTDATE;
        break;
    case DATEFORM_DMY:
        env2 |= INF_E2_DAYMONTH;
        break;
    }
    switch(G.g_cnxsave.cs_timefmt)
    {
    case TIMEFORM_IDT:
        env2 |= INF_E2_IDTTIME;
        break;
    case TIMEFORM_24H:
        env2 |= INF_E2_24HCLOCK;
        break;
    }
    env2 |= sound(FALSE, 0xFFFF, 0)  ? 0x00 : INF_E2_SOUND;
#if CONF_WITH_VIDEL
    mode = get_videl_mode();
    if (!mode)                      /* i.e. not videl */
#endif
        mode = 0xff00 | Getrez();
    env5 = (G.g_cnxsave.cs_sort == CS_NOSORT) ? INF_E5_NOSORT : 0;
    pcurr += sprintf(pcurr,"#E %02X %02X %02X %02X %02X\r\n",
                    env1,env2,(mode>>8)&0x00ff,mode&0x00ff,env5);

    /* save windows */
    for (i = 0; i < NUM_WNODES; i++)
    {
        pws = &G.g_cnxsave.cs_wnode[i];
        ptmp = pws->pth_save;
        pcurr += sprintf(pcurr,"#W %02X %02X %02X %02X %02X %02X %02X",
                        0,pws->vsl_save,pws->x_save/gl_wchar,
                        pws->y_save/gl_hchar,pws->w_save/gl_wchar,
                        pws->h_save/gl_hchar,pws->obid_save);
        pcurr += sprintf(pcurr," %s@\r\n",(*ptmp!='@')?ptmp:"");
    }

    /*
     * reverse the ANODE list before we write it.  this ensures
     * that the generic ANODEs are written ahead of the ones
     * created for installed applications.  when we read it back
     * in, using app_alloc(TRUE) to allocate the ANODEs, the
     * generic ANODEs will once again be at the end of the list.
     */
    app_revit();

    /* save ANODE list */
    for (pa = G.g_ahead; pa; pa = pa->a_next)
    {
        switch(pa->a_type)
        {
        case AT_ISDISK:
            type = 'M';
            break;
        case AT_ISFILE:
            if (pa->a_flags & AF_WINDOW)
            {
                type = (pa->a_flags & AF_ISEXEC) ? 'I' : 'N';
                break;
            }
            if (pa->a_flags & AF_ISCRYS)
                type = (pa->a_flags & AF_ISPARM) ? 'Y' : 'G';
            else
                type = (pa->a_flags & AF_ISPARM) ? 'P' : 'F';
            break;
        case AT_ISFOLD:
            type = 'D';
            break;
        case AT_ISTRSH:     /* Trash */
            type = 'T';
            break;
        default:
            type = ' ';
        }
        pcurr += sprintf(pcurr,"#%c",type);
        if (pa->a_flags & AF_ISDESK)
            pcurr += sprintf(pcurr," %02X %02X",(pa->a_xspot/G.g_icw)&0x00ff,
                            (max(0,(pa->a_yspot-G.g_ydesk))/G.g_ich)&0x00ff);
        pcurr += sprintf(pcurr," %02X %02X",pa->a_aicon&0x00ff,pa->a_dicon&0x00ff);
        if (pa->a_flags & AF_ISDESK)
            pcurr += sprintf(pcurr," %c",pa->a_letter?pa->a_letter:' ');
        pcurr += sprintf(pcurr," %s@ %s@",pa->a_pappl,pa->a_pdata);
        if (pa->a_type == AT_ISFILE)
        {
            type = 0;
            if (pa->a_flags & AF_APPDIR)
                type |= INF_AT_APPDIR;
            if (pa->a_flags & AF_ISFULL)
                type |= INF_AT_ISFULL;
            pcurr += sprintf(pcurr," %X%02X %s@",type,pa->a_funkey,pa->a_pargs);
        }
        *pcurr++ = '\r';
        *pcurr++ = '\n';
    }
    *pcurr++ = 0x0;

    /* reverse list back */
    app_revit();

    /* calculate size */
    G.g_afsize = pcurr - gl_afile;

    /* save in memory */
    shel_put(gl_afile, G.g_afsize);

    /* save to disk */
    if (todisk)
        save_to_disk();
}
Ejemplo n.º 12
0
*cdecl cpx_init( XCPB *Xcpb )
{
    xcpb = Xcpb;

    currez = Getrez();				/* find current resolution */
    open_vwork();
    close_vwork();
    numcol = work_out[13];			/* size of CLUT */
    
    if( xcpb->booting )
    {
	if( saved )		/* if user-preference saved */
  	   init( &usr_vals );	/* init to saved user-preference */
        return( ( CPXINFO *)TRUE );  
    }
    else
    {    
      if( !xcpb->SkipRshFix )
      {
           (*xcpb->rsh_fix)( NUM_OBS, NUM_FRSTR, NUM_FRIMG, NUM_TREE,
                            rs_object, rs_tedinfo, rs_strings, rs_iconblk,
                            rs_bitblk, rs_frstr, rs_frimg, rs_trindex,
                            rs_imdope );
      }
 
      ad_tree = (OBJECT *)rs_trindex[ COLOR ];
      ActiveTree( ad_tree );
      HideObj( BASE2 );
      HideObj( BASE4 );
      HideObj( BASE16 );
      
      Disable( CSAVE );
      Disable( CRELOAD );
      
      /* set up color boxes on screen */
      switch( numcol )
      {
        case 2:   headbox = curbox = TWO01;
        	  col_page = 1;
        	  ShowObj( BASE2 );
        	  break;
        	  
        case 4:	  headbox = curbox = FOUR01;
        	  col_page = 1;
        	  ShowObj( BASE4 );
        	  break;
        	  
        default:  headbox = curbox = BOX0;
		  if (numcol == 16)			/* if 16 colors */
		      col_page = 2;			/* page by 2 colors */
		  else					/* if > 16 colors */
		      col_page = MAX_COL_SHOWN; /* page by max displayed */
        	  ShowObj( BASE16 );
        	  break;
      }


      /* set up color # slider */
      headcol = curcol = 0;		/* init color on screen */
      bpg = calc_bpg(work_out[39]);	/* calculate bits per gun */
      if( !bpg )
      {
        HideObj( RGBSLIDE );
      }
      else
      {
        Enable( CSAVE );
        Enable( CRELOAD );
	setup_bnk = touch_bnk = CLEAN;
	visit_bnk();	/* init data structures of current bank */

        curscrn[R] = curscrn[G] = curscrn[B] = -1;
        update_rgb(0);	/* init RGBs on screen */
      }
      col_max = numcol - 1;			
      (*xcpb->Sl_size)( tree, CBASE, CSLIDE, numcol, 1, VERTICAL, 16 );
      update_slid( CBASE, CSLIDE, curcol, col_max, col_min, 0 );
      
      /* Initialize the CPXINFO structure */           
      cpxinfo.cpx_call   = cpx_call;
      cpxinfo.cpx_draw   = NULL;
      cpxinfo.cpx_wmove  = NULL;
      cpxinfo.cpx_timer  = NULL;
      cpxinfo.cpx_key    = NULL;
      cpxinfo.cpx_button = NULL;
      cpxinfo.cpx_m1 	 = NULL;
      cpxinfo.cpx_m2	 = NULL;
      cpxinfo.cpx_hook   = NULL;
      cpxinfo.cpx_close  = NULL;

      /* Return the pointer to the CPXINFO structure to XCONTROL */
      return( &cpxinfo );
    }
}
Ejemplo n.º 13
0
init_sys()
{
    WORD work_in[11];
    WORD work_out[57];
    WORD i;



    save_critical();
    got_blitter = ( (_xbios(64, -1) & 3 ) == 3);
    if ( (gl_apid = appl_init()) == -1)
    {
        exit(-1);
    }
    aline = ainit();


    if (!init_mem())
        exit(-2);

    /* save initial rez ... we'll see if GEM agrees with this later */
    if ( (irez = Getrez()) != 0)
    {
        if (irez != 1)
        {
            puts("Cyber Paint can't run on black and white systems, sorry");
            for (i=0; i<60; i++)
            {
                Vsync();
            }
            exit(-3);
        }
    }

    get_cmap(color_env);
    copy_words(init_cmap, sys_cmap, COLORS);
    put_cmap(sys_cmap);
    initted_color = 1;

    if (!init_pulls())
        return(-4);

    /* save mouse wrap-around */
    mouse_bx = *((WORD *)(aline-692));
    mouse_by = *((WORD *)(aline-690));
    /* save # of colors gem thinks exist */
    gem_colr = *((WORD *)(aline-666));

    gr_handle = graf_handle(&gr_hwchar, &gr_hhchar, &gr_hwbox, &gr_hhbox);
    handle = gr_handle;
    stuff_words(work_in, 1, 10);
    work_in[10] = 2;
    v_opnvwk(work_in, &handle, work_out);
    if (handle == 0)
        return(-5);
    if (work_out[0] == 639)
    {
        gem_mrez = 1;	/* see what GEM thinks rez is in so file-requestor can
						work */
        /* poke in initial mouse location (in case off-screen for lo-rez */
        *((WORD *)(aline-602)) = 160;
        *((WORD *)(aline-600)) = 100;
    }
    jim_rez();
    pscreen = cscreen = (WORD *)Physbase();

    if ((uscreen = askmem(32000)) == NULL)
        return(-6);
    if ((start_screen = askmem(32000)) == NULL)
        return(-7);
    if ((end_screen = askmem(32000)) == NULL)
        return(-8);
    if ((prev_screen = laskmem(2L*32000L)) == NULL)
        /* prev/next form 64K buffer */
        return(-9);
    next_screen = prev_screen+16000;
    if ((bscreen = askmem(32000)) == NULL)
        return(-11);
    empty_ram_dlt();
    zero_screens();
    if (!init_input())
        return(-13);
    init_fname();
    init_menu_colors();
    install_critical();
    jimints_on();

    cel_mem_alloc = mem_free;	/* "user" memory starts here */

    return(1);
}
Ejemplo n.º 14
0
/*
** Description
** Initialize global variables, open vdi workstation etc
*/
void
init_global (WORD physical_vdi_id)
{
#if 0
  int        temp_vid;
  int        work_in[] = {1,1,1,1,1,1,1,1,1,1,2};
#endif
  int        work_out[57];
  int        dum;
  static int is_inited = FALSE;

  /* Only initialize globals if they haven't been initialized before */
  if(!is_inited)
  {
    is_inited = TRUE;
    
    DEBUG3 ("Entering init_global");
    
#if 0 /* FIXME def MINT_TARGET */
    /* Only mess with videomodes if running under MiNT */
    if(globals.video == 0x00030000L) {
      fprintf(stderr,"VsetMode\r\n");
      oldmode = globals.vmode = 3;
      oldmodecode = globals.vmodecode = VsetMode(-1);
      fprintf(stderr,"/VsetMode\r\n");
    }
    else {
      oldmode = globals.vmode = Getrez();
    };
#endif /* MINT_TARGET */
    
    global_common.mouse_owner = -1;
    global_common.realmove = 0;
    global_common.realsize = 0;
    global_common.realslide = 0;
    global_common.fnt_regul_id = -1;
    global_common.fnt_regul_sz = -1;
    global_common.icon_width = 48;
    global_common.icon_height = 56;
    global_common.wind_appl = 1;
    global_common.graf_mbox = 1;
    global_common.graf_growbox = 1;
    global_common.graf_shrinkbox = 1;
    global_common.fsel_sorted = 1;
    global_common.fsel_extern = 0;
    
    DEBUG3 ("init_global: 2");
    
#if 0 /* FIXME : Remove? def MINT_TARGET */
    fprintf(stderr,"appl_init()\r\n");
    own_appl_init();
    fprintf(stderr,"/appl_init()\r\n");
    
    if(open_physical_ws)
    {
      printf("No other AES found. Opening own Workstation.\r\n");
      work_in[0] = 5;
      v_opnwk(work_in,&global_common.vid,work_out);
      
      if(global_common.video == 0x00030000L)
      {
        VsetScreen(NULL, NULL, global_common.vmode, global_common.vmodecode);
      }
      else
      {
        VsetScreen((void*)-1, (void *)-1, global_common.vmode, global_common.vmodecode);
      }
    }
    else
    {
      printf("Other AES detected.\r\n");
      global_common.vid = own_graf_handle();
      v_clrwk(global_common.vid);
    }
#endif
    
    global_common.physical_vdi_id = physical_vdi_id;
    DEBUG2 ("lib_global.c: init_global: calling vq_extnd");
    vq_extnd (physical_vdi_id, 0, work_out);
    
    
    global_common.screen.x = 0;
    global_common.screen.y = 0;
    global_common.screen.width = work_out[0] + 1;
    global_common.screen.height = work_out[1] + 1;
    
    global_common.num_pens = work_out[13];
    
    vq_extnd (physical_vdi_id, 1, work_out);
    global_common.num_planes = work_out[4];
    
    /* setup systemfont information */
    
    if(global_common.screen.height >= 400)
    {
      global_common.fnt_regul_id = 1;
      global_common.fnt_regul_sz = 13;
    }
    else
    {
      global_common.fnt_regul_id = 1;
      global_common.fnt_regul_sz = 9;
    }
    
    global_common.fnt_small_id = global_common.fnt_regul_id;
    global_common.fnt_small_sz = global_common.fnt_regul_sz / 2;
    
    vst_font (physical_vdi_id, global_common.fnt_regul_id);
    vst_point (physical_vdi_id,
               global_common.fnt_regul_sz,
               &dum,
               &dum,
               &dum,
               &dum);
    
    global_common.arrowrepeat = 100;
    
    DEBUG2 ("lib_global.c: init_global: calling vqt_attributes");
    vqt_attributes (physical_vdi_id, work_out);
    
    global_common.blwidth = work_out[8] + 3;
    global_common.blheight = work_out[9] + 3;
    global_common.clwidth = work_out[8];
    global_common.clheight = work_out[9];
    
    global_common.bswidth = work_out[8] / 2 + 3;
    global_common.bsheight = work_out[9] / 2 + 3;
    global_common.cswidth = work_out[8] / 2;
    global_common.csheight = work_out[9] / 2;
    
    global_common.time = 0L;
    
#ifndef MINT_TARGET
    global_common.callback_handler = oaesis_callback;
#endif
    
    DEBUG2("lib_global.c: init_global: Calling Rsrc_do_rcfix");
    Rsrc_do_rcfix (physical_vdi_id,
                   (RSHDR *)resource,
                   FALSE
                   ,
                   TRUE
                   );
    DEBUG2("lib_global.c: init_global: Called Rsrc_do_rcfix");
    
    Rsrc_do_gaddr((RSHDR *)resource,
                  R_TREE,
                  AICONS,
                  &global_common.aiconstad,
                  TRUE); 
    DEBUG3("init_global: 10");
    Rsrc_do_gaddr((RSHDR *)resource,
                  R_TREE,
                  ALERT,
                  &global_common.alerttad,
                  TRUE);
    Rsrc_do_gaddr((RSHDR *)resource,
                  R_TREE,
                  FISEL,
                  &global_common.fiseltad,
                  TRUE);

    Rsrc_do_gaddr((RSHDR *)resource,
                  R_TREE,
                  PMENU,
                  &global_common.pmenutad,
                  TRUE);
    Rsrc_do_gaddr((RSHDR *)resource,
                  R_FRSTR,
                  0,
                  (OBJECT **)&global_common.fr_string,
                  TRUE);
    
    /* Initialize window elements and resource counters */
    Rsrc_do_gaddr((RSHDR *)resource,
                  R_TREE,
                  WINDOW,
                  &global_common.windowtad,
                  TRUE);
    global_common.elemnumber = -1;
 
    DEBUG3("init_global: 11");
    /* Init mouseforms */
    Rsrc_do_rcfix (physical_vdi_id,
                   (RSHDR *)cursors,
                   FALSE
                   ,
                   TRUE
                   );
    DEBUG3("init_global: 12");
    Rsrc_do_gaddr((RSHDR *)cursors,
                  R_TREE,
                  MOUSEFORMS,
                  &global_common.mouseformstad,
                  TRUE);
    DEBUG3("init_global: 13");
    Graf_init_mouseforms();
    
    DEBUG3("init_global: 14");
#ifdef MINT_TARGET
    /* Initialize semaphore used by Shel_do_write */
    Psemaphore(SEM_CREATE, SHEL_WRITE_LOCK, 0);
    Psemaphore(SEM_UNLOCK, SHEL_WRITE_LOCK, 0);
#endif
  }
}
Ejemplo n.º 15
0
/*
 * Set up screen for VT52.
 * This is called by os_askfile to restore the screen to the normal
 * state, so it shouldn't allocate data structures.
 */
vt_setup()
{
    int     i;

    /*
     * Get rid of the mouse
     */
    graf_mouse(M_OFF, NULL);

    /*
     * Get desktop resolution.  If monochrome, note the fact so that
     * we can make sure our color choices get set correctly later on.
     * If low resolution, change to medium resolution automagically.
     *
     * If any other resolution, don't do anything different, and hope
     * things work out OK.
     */
    drez = Getrez();
    if (drez == 0)
        Setscreen(-1L, -1L, 1);

    if (drez != 2) {
        /*
         * Get desktop palette.
         */
        for (i = 0; i < 16; i++)
            dpalette[i] = Setcolor(i, -1);

        /*
         * Set our palette.
         */
        Setpalette(palette);

        /*
         * Tell the rest of the system what good colors
         * are for various things.
         */
        sdesc_color = colbyte(osWHITE, osBLUE);
        ldesc_color = colbyte(osBLACK, osWHITE);
        debug_color = colbyte(osBRIGHTWHITE, osBLACK);
        text_color  = colbyte(osWHITE, osBLACK);
        text_bold_color = colbyte(osBRIGHTWHITE, osBLACK);
        text_normal_color = text_color;
    }
    else {
        /*
         * Monochrome -- note different color name constants
         */
        sdesc_color = colbyte(osmREVERSE, osmREVERSE);
        ldesc_color = colbyte(osmREVERSE, osmREVERSE);
        debug_color = colbyte(osmNORMAL, osmNORMAL);
        text_color  = colbyte(osmNORMAL, osmNORMAL);
        text_bold_color = colbyte(osmREVERSE, osmREVERSE);
        text_normal_color = text_color;
    }

    /*
     * Set default text color
     */
    vt_color(text_color);

    /*
     * Clear the screen, set to no-wrap mode, and enable cursor.
     * Also, set drawing colors to normal.
     */
    Cconws("\033E\033w\033e");
    X = 0;
    Y = 0;

    /*
     * Make the cursor not blink.
     */
    Cursconf(2, 0);
}
Ejemplo n.º 16
0
static double real_cputime() {
  long thetime;
  ptime = &thetime;
  xbios(38, gettime);
  return (((double)thetime) / (Getrez() == 2 ? 70 : 60));
}