Example #1
0
void cree_degrade(int start, int end)
{
  float r, g, b ;
  float c ;
  int   rgb[3] ;
  int   srgb[3] ;
  int   ergb[3] ;
  int   i ;
  int   nb ;

  if (start > end)
  {
    i     = start ;
    start = end ;
    end   = i ;
  }

  vq_color(handle, start, 0, srgb) ;
  vq_color(handle, end, 0, ergb) ;
  nb = 1+end-start ;
  r = (float)(ergb[0]-srgb[0])/(float)nb ;
  g = (float)(ergb[1]-srgb[1])/(float)nb ;
  b = (float)(ergb[2]-srgb[2])/(float)nb ;
  for (i = start; i <= end; i++)
  {
    c      = (float)srgb[0]+(float)(i-start)*r ;
    rgb[0] = (int) c ;
    c      = (float)srgb[1]+(float)(i-start)*g ;
    rgb[1] = (int) c ;
    c      = (float)srgb[2]+(float)(i-start)*b ;
    rgb[2] = (int) c ;
    vs_color(handle, i, rgb) ;
  }
}
Example #2
0
/*
 * Update and draw (if requested) text in the RGB sliders
 */
void
update_rgb(int draw)
{
	RGB *ptr;		/* ptr to RGB intensities of current color */
	
    /* Inquire the RGB intensities for current pen */
    ptr = curnew + curcol;
    open_vwork();
    vq_color(vhandle, curcol, 0, (int *)ptr);
    close_vwork();
	
    /* Update the RGB gun values for current pen */
    oldscrn[R] = curscrn[R];
    oldscrn[G] = curscrn[G];
    oldscrn[B] = curscrn[B];
    curscrn[R] = int2val(ptr->rint);
    curscrn[G] = int2val(ptr->gint);
    curscrn[B] = int2val(ptr->bint);
	    		
	/* Record old location of sliders, and update indices	*/
    /* on R, G and B sliders if necessary 					*/
    if (oldscrn[R] != curscrn[R])
		update_slid(VERTICAL, RBASE, RSLID, curscrn[R], val_min, 
			val_max, draw);
    
    if (oldscrn[G] != curscrn[G])
		update_slid(VERTICAL, GBASE, GSLID, curscrn[G], val_min, 
			val_max, draw);
    
    if (oldscrn[B] != curscrn[B])
		update_slid(VERTICAL, BBASE, BSLID, curscrn[B], val_min, 
			val_max, draw);
}
Example #3
0
void OnInitDialogPal(void *w)
{
  GEM_WINDOW     *wnd = (GEM_WINDOW *) w ;
  WEXTENSION_PAL *wext = wnd->DlgData->UserData ;
  OBJECT         *adr_mkpal = wnd->DlgData->BaseObject ;
  int            off_y ;
  char           buf[15] ;

  adr_mkpal[MKPAL_BOX].ob_spec.userblk->ub_code = draw_colors ;
  adr_mkpal[MKPAL_BOX].ob_spec.userblk->ub_parm = (long) wext ;
  adr_mkpal[MKPAL_CURRCOL].ob_spec.userblk->ub_code = draw_currentcolor ;
  adr_mkpal[MKPAL_CURRCOL].ob_spec.userblk->ub_parm = (long) wext ;

  get_vdipalette( wext->curr_pal ) ;
  wext->index = 0 ;
  wext->stdeg = wext->enddeg = 500 ;
  wext->hf    = (float) (adr_mkpal[MKPAL_REDBOX].ob_height-adr_mkpal[MKPAL_RED].ob_height) ;
  vq_color(handle, wext->index, 0, wext->rgb) ;
  sprintf(buf, "%.4d",wext->rgb[0]) ;
  write_text(adr_mkpal, MKPAL_TRED, buf) ;
  sprintf(buf, "%.4d", wext->rgb[1]) ;
  write_text(adr_mkpal, MKPAL_TGREEN, buf) ;
  sprintf(buf, "%.4d", wext->rgb[2]) ;
  write_text(adr_mkpal, MKPAL_TBLUE, buf) ;
  off_y = (int) ((1000-wext->rgb[0])*(float)wext->hf/1000.0) ;
  adr_mkpal[MKPAL_RED].ob_y = off_y ;
  off_y = (int) ((1000-wext->rgb[1])*(float)wext->hf/1000.0) ;
  adr_mkpal[MKPAL_GREEN].ob_y = off_y ;
  off_y = (int) ((1000-wext->rgb[2])*(float)wext->hf/1000.0) ;
  adr_mkpal[MKPAL_BLUE].ob_y = off_y ;
  wext->flag_aff = 0 ;
}
Example #4
0
/*
 * Update all data structures of current bank
 *
 * set - 0: no need to set to current bank
 *       1: set to current bank
 */
void
visit_bnk(int set)
{	
	int i;		/* counter */
	RGB *ptr;	/* temp pointer */
	
	/* init pointers to offset to current bank */
	i = curbnk * numcol;			/* color 0 of current bank */
	curold = (RGB *)&oldrgb[i];		/* old RGBs of current bank */
	curnew = (RGB *)&newrgb[i];		/* new RGBs of current bank */
	curdirt = (char *)&dirt_col[i];	/* dirty list for current bank */
	
	if (set)						/* set to current bank if requested */
		EsetBank(curbnk);
		
	/* if bank has never been setup before, fill data structures */
	if (setup_bnk[curbnk] == CLEAN) {
		open_vwork();
		for (i = 0, ptr = curnew; i < numcol; i++, ptr = curnew+i) {
				vq_color(vhandle, i, 0, (int *)ptr);
				*(curold+i) = *ptr;
				*(curdirt+i) = CLEAN;
		}
		close_vwork();
		setup_bnk[curbnk] = DIRTY;	/* remember it's been setup */
	}

}
Example #5
0
void get_colors(int handle, short *palette, int col)
{
    int i, idx;

    /* get current color palette */
    for(i=0; i < col; i ++) {
        /* device->vdi->device palette order */
        switch(planes) {
        case 1:
            idx=i;
            break;
        case 2:
            idx=vdi2dev2[i];
            break;
        case 4:
            idx=vdi2dev4[i];
            break;
        default:
            if(i<16)
                idx=vdi2dev4[i];
            else
                idx= i==255 ? 1 : i;
        }
        vq_color(handle, i, 0, (int *)palette + idx * 3);
    }
}
Example #6
0
/*
 * Re-initialize color registers with the last requested values
 */
void
reinitcol(void)
{
	int i, *ptr;		/* index */
	
	open_vwork();
	for (i = 0, ptr = (int *)curnew; 
		i < numcol; 
		i++, ptr = (int *)(curnew+i)) {
		vq_color(vhandle, i, 0, ptr);
		vs_color(vhandle, i, ptr);
	}
	close_vwork();
}
Example #7
0
/*
 * Set VDI color lookup table with the given RGB intensities
 * Passed:
 *			RGB col_array[] - array of RGB intensities
 */
void
slamcol(RGB col_array[])
{
	int i;		/* counter */
	
	open_vwork();
 	for (i = 0; i < numcol; i++) {
 		if (col_array[i].rint == -1) {
 			vq_color(vhandle, i, 0, (int *)&col_array[i]);
		}
		vs_color(vhandle, i, (int *)&col_array[i]);
	}
	close_vwork();
}
static void GEM_ClearRect(_THIS, short *rect)
{
	short oldrgb[3], rgb[3]={0,0,0};

	vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
	vs_color(VDI_handle, vdi_index[0], rgb);

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

	vs_color(VDI_handle, vdi_index[0], oldrgb);
}
Example #9
0
int *get_colors(void)
{
	int i, *colors, *h;

	if ((colors = malloc((long) ncolors * 3L * sizeof(int))) != NULL)
	{
		h = colors;

		for (i = 0; i < ncolors; i++)
		{
			vq_color(vdi_handle, i, 0, h);
			h += 3;
		}
	}

	return colors;
}
Example #10
0
static void GEM_ClearScreen(_THIS)
{
    short rgb[3]= {0,0,0};
    short oldrgb[3];
    short pxy[4];

    v_hide_c(VDI_handle);

    vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
    vs_color(VDI_handle, vdi_index[0], rgb);

    pxy[0] = pxy[1] = 0;
    pxy[2] = VDI_w - 1;
    pxy[3] = VDI_h - 1;
    vsf_color(VDI_handle,0);
    vsf_interior(VDI_handle,1);
    vsf_perimeter(VDI_handle,0);
    v_bar(VDI_handle,pxy);

    vs_color(VDI_handle, vdi_index[0], oldrgb);

    v_show_c(VDI_handle, 1);
}
Example #11
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);
}
Example #12
0
/*
 * Initialize system with given information.
 */
void
init(DEFAULTS *info)
{
	int i;	/* counter */
	
	open_vwork();
	
	/* if not boot time, on a color system and has more than 1 bank */
	if (!xcpb->booting && bpg && numbnk > 1) {
		for (curbnk = BNK_MIN; curbnk < NUM_BNK; curbnk++) {
			if (setup_bnk[curbnk] == CLEAN) {
				setup_bnk[curbnk] = DIRTY;
				visit_bnk(1);
				for (i = 0; i < numcol; i++) {
					vq_color(vhandle, i, 0, (int *)(curold+i));
				}
			}
		}
	}

	switch((int)curmode) {
		case TTVDO:					/* if TT video */
		
			if (info->gray != -1) {	/* set to color or gray scales */
				Vsync();
				EsetGray(info->gray);
			}
					
			switch(currez) {
				default:					/* in ST Low/Med, TT Med rez */
					if (info->bnk != -1) {
						EsetBank(0);
						slamcol(info->ubnk0.orez);
						/* set up colors in every bank */
						for (i = BNK_MIN+1; i < NUM_BNK; i++) {
							EsetBank(i);
							slamcol(info->obnk[i-1]);
						}
					
						/* set to desired bank */
						EsetBank(info->bnk);
					}
					break;	
					
				case STHI:					/* if in ST high rez */
					/* if invert state is saved, set it */
					if (info->inv != -1) {
						flip(1, &info->inv);
						if (!(info->inv & NOT_FLIPPED)) {
							swaprgb(&info->ubnk0.orez[0],
									&info->ubnk0.orez[1]);
							slamcol(info->ubnk0.orez);
							swaprgb(&info->ubnk0.orez[0],
									&info->ubnk0.orez[1]);
						} else {
							slamcol(info->ubnk0.orez);
						}
					} else {
						slamcol(info->ubnk0.orez);
					}
					break;
				
				case TTLOW:					/* if in TT low rez */
					slamcol(info->ubnk0.ttlow);
					break;
						
				case TTHI:					/* if in TT high rez */
					/* do nothing */
					break;
			}
			break;
			
		case STVDO:					/* if ST or STE video */
		case STEVDO:
			if (currez == STHI)	{			/* if in ST high rez */
				if (info->inv != -1)			/* if invert state saved */
					flip(1, &info->inv);		/* set to it */
			} else {
				slamcol(info->ubnk0.orez);
			}
			break;
	}
	
	if (!xcpb->booting) {		/* if not boot time */
		if (currez == STHI) {
			if (curinv != info->inv) {
				if (!(info->inv & NOT_FLIPPED))
					Select(INVRSVDO);
				draw_button(INVRSVDO);
				Deselect(INVRSVDO);
				curinv = info->inv;
			}
		}
						
		if ((int)curmode == TTVDO && currez != TTHI) {
			if (curgray != info->gray) {
				if (info->gray) {
					HideObj(SETGRAY);
					i = SETCOL;
				} else {
					HideObj(SETCOL);
					i = SETGRAY;
				}
				ShowObj(i);
				draw_button(i);
				curgray = info->gray;
			}
		}
		
		if (bpg) {				
			if (numbnk == 1) {
				touch_bnk[0] = DIRTY;
				for (i = 0; i < numcol; i++) {
					vq_color(vhandle, i, 0, (int *)(curnew+i));
					*(curdirt+i) = DIRTY;
				}
			} else {
				for (curbnk = BNK_MIN; curbnk < numbnk; curbnk++) {
					touch_bnk[curbnk] = setup_bnk[curbnk] = DIRTY;
					visit_bnk(1);
					for (i = 0; i < numcol; i++) {
						vq_color(vhandle, i, 0, (int *)(curnew+i));
						*(curdirt+i) = DIRTY;
					}
				}
				curbnk = info->bnk;
				visit_bnk(1);
				update_slid(HORIZONTAL, BNKBASE, BNKSLID, curbnk, 
					BNK_MIN, BNK_MAX, 1);
			}
			update_rgb(1);
		}
	}
	close_vwork();
 }
Example #13
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);
}
Example #14
0
/* *** Beim GEM anmelden *** */
int initGEM(void)
{
 int rgb[3];
 int work_in[12], work_out[57];		/* VDI-Felder */
 int i, ap_id;

 ap_id=appl_init();
 if(ap_id==-1)	return(-1);
 if(aesversion>=0x400)					/* Wenn m�glich einen Namen anmelden */
	menu_register(ap_id, "  STed\0\0\0\0");
 graf_mouse(ARROW, 0L);					/* Maus als Pfeil */

 if( !rsrc_load("sted.rsc") )
  {
   form_alert(1, "[3][Could not|load <sted.rsc>][Cancel]");
   appl_exit();
   return(-1);
  }
 rsrc_gaddr(R_TREE, MAINMENU, &menu);	/* Adresse holen */
 rsrc_gaddr(R_TREE, ABOUTSED, &aboutdlg);
 rsrc_gaddr(R_TREE, LDATDIA, &lvdatdlg);

#ifdef RESTRIC_STED
 lvdatdlg[LVLTYP].ob_flags |= HIDETREE;
 lvdatdlg[LVLTYP].ob_flags &= ~EDITABLE;
 lvdatdlg[LVLTYPT1].ob_flags |= HIDETREE;
 lvdatdlg[LVLTYPT2].ob_flags |= HIDETREE;
 lvdatdlg[LVLID].ob_flags |= HIDETREE;
 lvdatdlg[LVLID].ob_flags &= ~EDITABLE;
 lvdatdlg[LVLIDT1].ob_flags |= HIDETREE;
#endif

 wind_get(0, WF_WORKXYWH, &deskx, &desky, &deskw, &deskh); /* Desktopgr��e */

 vhndl=graf_handle(&i, &i, &i, &i);
 for(i=0; i<10; i++)	work_in[i]=1;
 work_in[10]=2;
 v_opnvwk(work_in, &vhndl, work_out);	/* VDI-Station �ffnen */

 vq_extnd(vhndl, 1, work_out);
 bipp=work_out[4];						/* Bits pro Bitplane ermitteln */
 if(bipp>8)
  {
   form_alert(1, "[3][Sorry, STed only works|in 16 and 256 colors!][Ok]");
   v_clsvwk(vhndl); rsrc_free(); appl_exit();
   return(-1);
  }

 menu_bar(menu, 1);			/* Men� darstellen */

 for(i=0; i<15; i++)		/* Alte Farben sichern */
  {
   vq_color(vhndl, i, 1, rgb);
   oldpal[i][0]=rgb[0];
   oldpal[i][1]=rgb[1];
   oldpal[i][2]=rgb[2];
  }
 setpal(newpal);			/* Neue Farben setzen */

 return(0);
}
Example #15
0
int OnObjectNotifyPal(void *w, int obj)
{
  GEM_WINDOW     *wnd = (GEM_WINDOW *) w ;
  WEXTENSION_PAL *wext = wnd->DlgData->UserData ;
  OBJECT         *adr_mkpal = wnd->DlgData->BaseObject ;
  int            off_x, off_y ;
  int            xm, ym, dummy ;
  int            pb_x, pb_y ;
  int            x1, y1, x2, y2 ;
  int            code = -1 ;
  char           buf[15] ;

  graf_mkstate( &xm, &ym, &dummy, &dummy ) ;

  switch( obj )
  {
    case MKPAL_MRED      :
    case MKPAL_PRED      : if ( obj == MKPAL_PRED ) wext->curr_rgb[0]++ ;
                           else                     wext->curr_rgb[0]-- ;
                           if (wext->curr_rgb[0] < 1)    wext->curr_rgb[0] = 1 ;
                           if (wext->curr_rgb[0] > 1000) wext->curr_rgb[0] = 1000 ;
                           off_y = (int) ((1000-wext->curr_rgb[0])*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_RED].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_REDBOX ) ;
                           sprintf(buf, "%.4d", wext->curr_rgb[0]) ;
                           write_text(adr_mkpal, MKPAL_TRED, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TRED ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_MGREEN    :
    case MKPAL_PGREEN    : if ( obj == MKPAL_PGREEN ) wext->curr_rgb[1]++ ;
                           else                       wext->curr_rgb[1]-- ;
                           if (wext->curr_rgb[1] < 1)    wext->curr_rgb[1] = 1 ;
                           if (wext->curr_rgb[1] > 1000) wext->curr_rgb[1] = 1000 ;
                           off_y = (int) ((1000-wext->curr_rgb[1])*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_GREEN].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_GREENBOX ) ;
                           sprintf(buf, "%.4d", wext->curr_rgb[1]) ;
                           write_text(adr_mkpal, MKPAL_TGREEN, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TGREEN ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_MBLUE     :
    case MKPAL_PBLUE     : if ( obj == MKPAL_PBLUE ) wext->curr_rgb[2]++ ;
                           else                      wext->curr_rgb[2]-- ;
                           if (wext->curr_rgb[2] < 1)    wext->curr_rgb[2] = 1 ;
                           if (wext->curr_rgb[2] > 1000) wext->curr_rgb[2] = 1000 ;
                           off_y = (int) ((1000-wext->curr_rgb[2])*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_BLUE].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_BLUEBOX ) ;
                           sprintf(buf, "%.4d", wext->curr_rgb[2]) ;
                           write_text(adr_mkpal, MKPAL_TBLUE, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TBLUE ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_REDBOX    : 
                           objc_offset(adr_mkpal, MKPAL_RED, &off_x, &off_y) ;
                           if (ym > off_y) wext->curr_rgb[0] = wext->curr_rgb[0]-20 ;
                           else            wext->curr_rgb[0] = wext->curr_rgb[0]+20 ;
                           if (wext->curr_rgb[0] < 1)    wext->curr_rgb[0] = 1 ;
                           if (wext->curr_rgb[0] > 1000) wext->curr_rgb[0] = 1000 ;
                           off_y = (int) ((1000-wext->curr_rgb[0])*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_RED].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_REDBOX ) ;
                           sprintf(buf, "%.4d", wext->curr_rgb[0]) ;
                           write_text(adr_mkpal, MKPAL_TRED, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TRED ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_GREENBOX  : 
                           objc_offset(adr_mkpal, MKPAL_GREEN, &off_x, &off_y) ;
                           if (ym > off_y) wext->curr_rgb[1] = wext->curr_rgb[1]-20 ;
                           else            wext->curr_rgb[1] = wext->curr_rgb[1]+20 ;
                           if (wext->curr_rgb[1] < 1)  wext->curr_rgb[1] = 1 ;
                           if (wext->curr_rgb[1] > 1000) wext->curr_rgb[1] = 1000 ;
                           off_y = (int) ((1000-wext->curr_rgb[1])*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_GREEN].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_GREENBOX ) ;
                           sprintf(buf, "%.4d", wext->curr_rgb[1]) ;
                           write_text(adr_mkpal, MKPAL_TGREEN, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TGREEN ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_BLUEBOX   : 
                           objc_offset(adr_mkpal, MKPAL_BLUE, &off_x, &off_y) ;
                           if (ym > off_y) wext->curr_rgb[2] = wext->curr_rgb[2]-20 ;
                           else            wext->curr_rgb[2] = wext->curr_rgb[2]+20 ;
                           if (wext->curr_rgb[2] < 1)    wext->curr_rgb[2] = 1 ;
                           if (wext->curr_rgb[2] > 1000) wext->curr_rgb[2] = 1000 ;
                           off_y = (int) ((1000-wext->curr_rgb[2])*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_BLUE].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_BLUEBOX ) ;
                           sprintf(buf, "%.4d", wext->curr_rgb[2]) ;
                           write_text(adr_mkpal, MKPAL_TBLUE, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TBLUE ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_RED       : wext->curr_rgb[0] = (float) graf_slidebox(adr_mkpal, MKPAL_REDBOX, MKPAL_RED, 1) ;
                           off_y = (int) (wext->curr_rgb[0]*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_RED].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_REDBOX ) ;
                           wext->curr_rgb[0] = 1000-wext->curr_rgb[0] ;
                           sprintf(buf, "%.4d", wext->curr_rgb[0]) ;
                           write_text(adr_mkpal, MKPAL_TRED, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TRED ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
     case MKPAL_GREEN    : wext->curr_rgb[1] = (float) graf_slidebox(adr_mkpal, MKPAL_GREENBOX, MKPAL_GREEN, 1) ;
                           off_y = (int) (wext->curr_rgb[1]*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_GREEN].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_GREENBOX ) ;
                           wext->curr_rgb[1] = 1000-wext->curr_rgb[1] ;
                           sprintf(buf, "%.4d", wext->curr_rgb[1]) ;
                           write_text(adr_mkpal, MKPAL_TGREEN, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TGREEN ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_BLUE      : wext->curr_rgb[2] = (float) graf_slidebox(adr_mkpal, MKPAL_BLUEBOX, MKPAL_BLUE, 1) ;
                           off_y = (int) (wext->curr_rgb[2]*(float)wext->hf/1000.0) ;
                           adr_mkpal[MKPAL_BLUE].ob_y = off_y ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_BLUEBOX ) ;
                           wext->curr_rgb[2] = 1000-wext->curr_rgb[2] ;
                           sprintf(buf, "%.4d", wext->curr_rgb[2]) ;
                           write_text(adr_mkpal, MKPAL_TBLUE, buf) ;
                           xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_TBLUE ) ;
                           vs_color(handle, wext->index, wext->curr_rgb) ;
                           break ;
    case MKPAL_LOAD     : charge_palette() ;
                          deselect(adr_mkpal, obj) ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, obj ) ;
                          wext->flag_aff = 0 ;
                          break ;
    case MKPAL_SAVE     : sauve_palette() ;
                          deselect(adr_mkpal, obj) ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, obj ) ;
                          wext->flag_aff = 0 ;
                          break ;
    case MKPAL_START    :
    case MKPAL_END      : if ( obj == MKPAL_START ) wext->stdeg  = wext->index ;
                          else                      wext->enddeg = wext->index ;
                          if (selected(adr_mkpal, MKPAL_START) && selected(adr_mkpal, MKPAL_END))
                          {
                            deselect(adr_mkpal, MKPAL_START) ;
                            deselect(adr_mkpal, MKPAL_END) ;
                            xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_START ) ;
                            xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_END ) ;
                            cree_degrade(wext->stdeg, wext->enddeg) ;
                            wext->stdeg = wext->enddeg = 500 ;
                          }
                          break ;
    case MKPAL_APPLIQUE : read_text(adr_mkpal, MKPAL_TRED, buf) ;
                          wext->rgb[0] = atoi(buf) ;
                          off_y = (int) ((1000-wext->rgb[0])*(float)wext->hf/1000.0) ;
                          adr_mkpal[MKPAL_RED].ob_y = off_y ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_REDBOX ) ;
                          read_text(adr_mkpal, MKPAL_TGREEN, buf) ;
                          wext->rgb[1] = atoi(buf) ;
                          off_y = (int) ((1000-wext->rgb[1])*(float)wext->hf/1000.0) ;
                          adr_mkpal[MKPAL_GREEN].ob_y = off_y ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_GREENBOX ) ;
                          read_text(adr_mkpal, MKPAL_TBLUE, buf) ;
                          wext->rgb[2] = atoi(buf) ;
                          off_y = (int) ((1000-wext->rgb[2])*(float)wext->hf/1000.0) ;
                          adr_mkpal[MKPAL_BLUE].ob_y = off_y ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_BLUEBOX ) ;
                          vs_color(handle, wext->index, wext->rgb) ;
                          deselect(adr_mkpal, obj) ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, obj ) ;
                          break ;
    case MKPAL_BOX      : objc_offset(adr_mkpal, obj, &pb_x, &pb_y) ;
                          if (wext->flag_aff)
                          {
                            x1 = pb_x+(wext->index % wext->nb_col_x)*wext->ww ;
                            y1 = pb_y+(wext->index / wext->nb_col_x)*wext->hh ;
                            x2 = x1+wext->ww-1 ;
                            y2 = y1+wext->hh-1 ;
                            vsf_color(handle, 1) ;
                            vswr_mode(handle, MD_XOR) ;
                            vsl_width(handle, 3) ;
                            v_hide_c(handle) ;
                            rectangle(x1, y1, x2, y2) ;
                            v_show_c(handle, 1) ;
                          }
                          else wext->flag_aff = 1 ;
                          graf_mkstate(&xm, &ym, &dummy, &dummy) ;
                          wext->index = (xm-pb_x)/wext->ww+ wext->nb_col_x*((ym-pb_y)/wext->hh) ;
                          vq_color(handle, wext->index, 0, wext->rgb) ;
                          sprintf(buf, "%.4d", wext->rgb[0]) ;
                          write_text(adr_mkpal, MKPAL_TRED, buf) ;
                          sprintf(buf, "%.4d", wext->rgb[1]) ;
                          write_text(adr_mkpal, MKPAL_TGREEN, buf) ;
                          sprintf(buf, "%.4d", wext->rgb[2]) ;
                          write_text(adr_mkpal, MKPAL_TBLUE, buf) ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_RGB ) ;
                          x1 = pb_x+wext->ww*((xm-pb_x)/wext->ww) ;
                          y1 = pb_y+wext->hh*((ym-pb_y)/wext->hh) ;
                          x2 = x1+wext->ww-1 ;
                          y2 = y1+wext->hh-1 ;
                          vsf_color(handle, 1) ;
                          v_hide_c(handle) ;
                          vswr_mode(handle, MD_XOR) ;
                          vsl_width(handle, 3) ;
                          rectangle(x1, y1, x2, y2) ;
                          v_show_c(handle, 1) ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_CURRCOL ) ;
                          off_y = (int) ((1000-wext->rgb[0])*(float)wext->hf/1000.0) ;
                          adr_mkpal[MKPAL_RED].ob_y = off_y ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_REDBOX ) ;
                          off_y = (int) ((1000-wext->rgb[1])*(float)wext->hf/1000.0) ;
                          adr_mkpal[MKPAL_GREEN].ob_y = off_y ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_GREENBOX ) ;
                          off_y = (int) ((1000-wext->rgb[2])*(float)wext->hf/1000.0) ;
                          adr_mkpal[MKPAL_BLUE].ob_y = off_y ;
                          xobjc_draw( wnd->window_handle,adr_mkpal, MKPAL_BLUEBOX ) ;
                          break ;
     case MKPAL_OK      : code = IDOK ;
                          break ;
     case MKPAL_CANCEL  : code = IDCANCEL ;
                          break ;
  }

  if ( code == IDOK )
  {

  }

  return( code ) ;
}
Example #16
0
void slideshow()
{
	VEIL				*tv;
	LEDP				*led;
	int				i,j,k,l;
	typedef int		t_rgb[3];
	t_rgb				*col;
	int				pal;
	long				len;
	int				wha,wx,wy,ww,wh;

	wind_update(BEG_MCTRL);
	graf_mouse(M_OFF,NULL);
	time(&t2);
	shift=(int)Kbshift(-1);

	if (glb.opt.deskfull)
	{
		wx=glb.aes.desk.x;		wy=glb.aes.desk.y;
		ww=glb.aes.desk.w;		wh=glb.aes.desk.h;
	}
	else
	{
		wx=0;							wy=0;
		ww=1+glb.vdi.wscr;		wh=1+glb.vdi.hscr;
	}
	wha=wind_create(0,0,0,1+glb.vdi.wscr,1+glb.vdi.hscr);
	if (wha<=0)
	{
		form_alert(1,glb.rsc.head.frstr[NOWIN]);
		graf_mouse(M_ON,NULL);
		graf_mouse(ARROW,NULL);
		wind_update(END_MCTRL);
		return;
	}

	_menuBar(glb.aes.tree.menu,FALSE);

	wind_open(wha,wx,wy,ww,wh);
	wind_get(wha,WF_CURRXYWH,&wx,&wy,&ww,&wh);

	if (glb.opt.is_tv && glb.opt.sl_tv)
	{
		tv=(VEIL *)_cookie('VeiL');
		j=(int)tv->stop;
		tv->stop=0xFF;
	}
	if (glb.opt.is_led && glb.opt.sl_led)
	{
		led=(LEDP *)_cookie('LEDP');
		k=led->active;
		led->active&=~1;
	}

	len=(long)glb.vdi.out[13]*(long)sizeof(t_rgb);
	pal=_mAlloc(len,FALSE);
	glb.opt.mask=0;
	if (pal!=NO_MEMORY)
	{
		col=(t_rgb *)glb.mem.adr[pal];
		for (i=0;i<glb.vdi.out[13];i++)
			vq_color(glb.vdi.ha,i,1,(int *)col[i]);
	}

	glb.div.slide=TRUE;

	l=Balaie_Path(glb.opt.sl_path,wx,wy,ww,wh);
	if (!l && glb.opt.sl_loop && num>0)
		do
		{
			l=Balaie_Path(glb.opt.sl_path,wx,wy,ww,wh);
		}	while (!l);

	glb.div.slide=FALSE;
	updFreeMem();

	if (pal!=NO_MEMORY)
	{
		col=(t_rgb *)glb.mem.adr[pal];
		for (i=0;i<glb.vdi.out[13];i++)
			vs_color(glb.vdi.ha,i,(int *)col[i]);
		_mFree(pal);
	}

	if (glb.opt.is_tv && glb.opt.sl_tv)
	{
		tv=(VEIL *)_cookie('VeiL');
		tv->stop=j;
	}
	if (glb.opt.is_led && glb.opt.sl_led)
	{
		led=(LEDP *)_cookie('LEDP');
		led->active=k;
	}

	wind_close(wha);
	wind_delete(wha);

	_menuBar(glb.aes.tree.menu,TRUE);

	graf_mouse(M_ON,NULL);
	graf_mouse(ARROW,NULL);
	wind_update(END_MCTRL);
}
Example #17
0
int ctor_plotter_vdi( GEM_PLOTTER self , GRECT * loc_size )
{
	int retval = 0;
	int i;
	struct rect clip;

	self->dtor = dtor;
	self->resize= resize;
	self->move = move;
	self->lock = lock;
	self->unlock = unlock;
	self->put_pixel = put_pixel;
	self->copy_rect = copy_rect;
	self->set_clip = set_clip;
	self->get_clip = get_clip;
	self->arc = arc;
	self->disc = disc;
	self->line = line;
	self->rectangle = rectangle;
	self->polygon = polygon;
	self->path = path;
	self->bitmap = bitmap;
	self->bitmap_resize = bitmap_resize;
	/* override virtual bpp - must be in sync with screen for this driver: 	*/
	self->bpp_virt = app.nplanes;
#ifdef WITH_8BPP_SUPPORT
	self->bitmap_convert =(app.nplanes > 8) ? bitmap_convert : bitmap_convert_8;
#else
	self->bitmap_convert = bitmap_convert;
#endif
	self->plot_mfdb = plot_mfdb;
	self->text = text;
	LOG(("Screen: x: %d, y: %d\n", vdi_sysinfo.scr_w, vdi_sysinfo.scr_h));

	self->priv_data = malloc( sizeof(struct s_vdi_priv_data) );
	if( self->priv_data == NULL )
		return( 0-ERR_NO_MEM );
	memset( self->priv_data, 0, sizeof(struct s_vdi_priv_data) );
	memset( &VIEW(self), 0, sizeof( struct s_view) );
	VIEW( self ).x = loc_size->g_x;
	VIEW( self ).y = loc_size->g_y;
	VIEW( self ).w = loc_size->g_w;
	VIEW( self ).h = loc_size->g_h;
	DUMMY_PRIV(self)->bufops = 0;
	DUMMY_PRIV(self)->size_buf_packed = 0;
	DUMMY_PRIV(self)->size_buf_planar = 0;
	DUMMY_PRIV(self)->buf_packed = NULL;
	DUMMY_PRIV(self)->buf_planar = NULL;
	if( vdi_sysinfo.vdiformat == VDI_FORMAT_PACK  ) {
		self->bpp_virt = vdi_sysinfo.scr_bpp;
	} else {
		DUMMY_PRIV(self)->bufops = C2P;
		self->bpp_virt = 8;
	}

	VIEW(self).mem = NULL;
	update_visible_rect( self );

	clip.x0 = 0;
	clip.y0 = 0;
	clip.x1 = VIEW(self).w;
	clip.y1 = VIEW(self).h;
	self->set_clip( self, &clip );

	assert( Hermes_Init() );
	/* store system palette & setup the new (web) palette: */
#ifdef WITH_8BPP_SUPPORT
	i = 0;

	unsigned char * col;
	unsigned char rgbcol[4];
	unsigned char graytone=0;
	if( app.nplanes <= 8 ){
		for( i=0; i<=255; i++ ) {

			// get the current color and save it for restore:
			vq_color(self->vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] );
			if( i<OFFSET_WEB_PAL ) {
				pal[i][0] = sys_pal[i][0];
		 		pal[i][1] = sys_pal[i][1];
				pal[i][2] = sys_pal[i][2];
			} else if( app.nplanes >= 8 ) {
				if ( i < OFFSET_CUST_PAL ){
					pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0];
					pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1];
					pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2];
					//set the new palette color to websafe value:
					vs_color( self->vdi_handle, i, &pal[i][0] );
				}
				if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) {
					/* here we define 20 additional gray colors... */
					rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4);
					rgb_to_vdi1000( &rgbcol[0], &pal[i][0] );
					vs_color( self->vdi_handle, i, &pal[i][0] );
					graytone++;
				}

			}
			vdi1000_to_rgb( &pal[i][0],  &rgb_lookup[i][0] );
		}

	} else {
		/* no need to change the palette - its application specific */
	}


#endif

	unsigned long flags = ( self->flags & PLOT_FLAG_DITHER ) ? HERMES_CONVERT_DITHER : 0;
	hermes_cnv_h = Hermes_ConverterInstance( flags );
	assert( hermes_cnv_h );
	hermes_res_h = Hermes_ConverterInstance( flags );
	assert( hermes_res_h );

	/* set up the src & dst format: */
	/* netsurf uses RGBA ... */
	DUMMY_PRIV(self)->nsfmt.a = 0xFFUL;
	DUMMY_PRIV(self)->nsfmt.b = 0x0FF00UL;
	DUMMY_PRIV(self)->nsfmt.g = 0x0FF0000UL;
	DUMMY_PRIV(self)->nsfmt.r = 0x0FF000000UL;
	DUMMY_PRIV(self)->nsfmt.bits = 32;
	DUMMY_PRIV(self)->nsfmt.indexed = false;
	DUMMY_PRIV(self)->nsfmt.has_colorkey = false;

	DUMMY_PRIV(self)->vfmt.r = vdi_sysinfo.mask_r;
	DUMMY_PRIV(self)->vfmt.g = vdi_sysinfo.mask_g;
	DUMMY_PRIV(self)->vfmt.b = vdi_sysinfo.mask_b;
	DUMMY_PRIV(self)->vfmt.a = vdi_sysinfo.mask_a;
	DUMMY_PRIV(self)->vfmt.bits = self->bpp_virt;
	DUMMY_PRIV(self)->vfmt.indexed = ( app.nplanes <= 8 ) ? 1 : 0;
	DUMMY_PRIV(self)->vfmt.has_colorkey = 0;

	return( 1 );
}
Example #18
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);
}
Example #19
0
/*----------------------------------------------------------------------------------------*/
COLOR_MAP	*_create_cmap( int16 vdi_handle )
{
	COLOR_MAP	*cmap;
	int32	length;
	int32	no_colors;
	int16	work_out[272];
	
	vq_scrninfo( vdi_handle, work_out );							/* Pixelwerte erfragen */
	no_colors = *(int32 *) ( work_out + 3 );						/* Farbanzahl */
	
	if (( no_colors == 0 ) || ( no_colors > 256 ))				/* Direct Color, Dummy-Palette erzeugen? */
	{
		int16	i;

		for ( i = 0; i < 256; i++ )
			work_out[16 + i] = i;
			
		no_colors = 256;
	}

	length = sizeof( COLOR_MAP ) + ( no_colors * sizeof( COLOR_ENTRY ));
	cmap = Malloc_sys( length );
	
	if ( cmap )
	{
		cmap->magic = 'cmap';
		cmap->length = length;											/* L�nge der Farbtabelle */
		cmap->format = 0;
		cmap->reserved = 0;
		
		cmap->map_id = 0;
		cmap->color_space = CSPACE_RGB;
		cmap->flags = CSPACE_3COMPONENTS;
		cmap->no_colors = no_colors;									/* Anzahl der Farben */

		cmap->reserved1 = 0;
		cmap->reserved2 = 0;
		cmap->reserved3 = 0;
		cmap->reserved4 = 0;
		
		while ( no_colors > 0 )
		{
			int16	rgb_out[3];
			COLOR_ENTRY	*entry;
			int16	value;

			no_colors--;
			vq_color( vdi_handle, (int16) no_colors, 1, rgb_out ); 
			value = work_out[16 + no_colors];						/* Pixelwert */

			entry = cmap->colors + value;								/* Eintrag in der Farbtabelle */
			entry->rgb.red = (((int32) rgb_out[0] << 8 ) - rgb_out[0] ) / 1000L;
			entry->rgb.red += entry->rgb.red << 8;
			entry->rgb.green = (((int32) rgb_out[1] << 8 ) - rgb_out[1] ) / 1000L;
			entry->rgb.green += entry->rgb.green << 8;
			entry->rgb.blue = (((int32) rgb_out[2] << 8 ) - rgb_out[2] ) / 1000L;
			entry->rgb.blue += entry->rgb.blue << 8;
			entry->rgb.reserved = value;
		}
	}

	return( cmap );
}