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); }
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); }
int appl_xgetinfo(int type, int *out1, int *out2, int *out3, int *out4) { return(has_agi ? appl_getinfo(type,out1,out2,out3,out4) : 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); }