Commit 058af532 authored by Patrice Mandin's avatar Patrice Mandin

Use new C2P routine + corrections for iconification window

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40737
parent b0055272
...@@ -219,6 +219,11 @@ static int do_messages(_THIS, short *message) ...@@ -219,6 +219,11 @@ static int do_messages(_THIS, short *message)
/* Send an internal deactivate event */ /* Send an internal deactivate event */
SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS);
} }
/* Update window title */
if (GEM_refresh_name && GEM_icon_name) {
wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0);
GEM_refresh_name = SDL_FALSE;
}
break; break;
case WM_UNICONIFY: case WM_UNICONIFY:
wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]); wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
...@@ -227,6 +232,10 @@ static int do_messages(_THIS, short *message) ...@@ -227,6 +232,10 @@ static int do_messages(_THIS, short *message)
/* Send an internal activate event */ /* Send an internal activate event */
SDL_PrivateAppActive(1, SDL_APPACTIVE); SDL_PrivateAppActive(1, SDL_APPACTIVE);
} }
if (GEM_refresh_name && GEM_title_name) {
wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
GEM_refresh_name = SDL_FALSE;
}
break; break;
case WM_SIZED: case WM_SIZED:
wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]); wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
......
...@@ -43,6 +43,8 @@ static char rcsid = ...@@ -43,6 +43,8 @@ static char rcsid =
/* Defines */ /* Defines */
/*#define DEBUG_VIDEO_GEM 1*/
#define MAXCURWIDTH 16 #define MAXCURWIDTH 16
#define MAXCURHEIGHT 16 #define MAXCURHEIGHT 16
...@@ -102,36 +104,46 @@ WMcursor *GEM_CreateWMCursor(_THIS, ...@@ -102,36 +104,46 @@ WMcursor *GEM_CreateWMCursor(_THIS,
new_mform->mf_fg = 0; new_mform->mf_fg = 0;
new_mform->mf_bg = 1; new_mform->mf_bg = 1;
for (i=0;i<MAXCURHEIGHT;i++) for (i=0;i<MAXCURHEIGHT;i++) {
{
new_mform->mf_mask[i]=0; new_mform->mf_mask[i]=0;
new_mform->mf_data[i]=0; new_mform->mf_data[i]=0;
} }
if (w<=8) { if (w<=8) {
for (i=0;i<h;i++) for (i=0;i<h;i++) {
{
new_mform->mf_mask[i]= mask[i]<<8; new_mform->mf_mask[i]= mask[i]<<8;
new_mform->mf_data[i]= data[i]<<8; new_mform->mf_data[i]= data[i]<<8;
} }
} else { } else {
for (i=0;i<h;i++) for (i=0;i<h;i++) {
{
new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1]; new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1];
new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1]; new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1];
} }
} }
#ifdef DEBUG_VIDEO_GEM
for (i=0; i<h ;i++) {
printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, new_mform->mf_mask[i]);
}
printf("sdl:video:gem: CreateWMCursor(): done\n");
#endif
return cursor; return cursor;
} }
int GEM_ShowWMCursor(_THIS, WMcursor *cursor) int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
{ {
/*
if (cursor == NULL) { if (cursor == NULL) {
graf_mouse(M_OFF, NULL); graf_mouse(M_OFF, NULL);
} else if (cursor->mform_p) { } else if (cursor->mform_p) {
graf_mouse(USER_DEF, cursor->mform_p); graf_mouse(USER_DEF, cursor->mform_p);
} }
*/
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
#endif
return 1; return 1;
} }
......
...@@ -26,13 +26,12 @@ static char rcsid = ...@@ -26,13 +26,12 @@ static char rcsid =
#endif #endif
/* /*
* GEM SDL video driver implementation GEM video driver
* inspired from the Dummy SDL driver
* Patrice Mandin
* Patrice Mandin and work from
* and work from Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
* Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard */
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -54,7 +53,6 @@ static char rcsid = ...@@ -54,7 +53,6 @@ static char rcsid =
#include "SDL_cursor_c.h" #include "SDL_cursor_c.h"
#include "SDL_ataric2p_s.h" #include "SDL_ataric2p_s.h"
#include "SDL_ataric2p060_c.h"
#include "SDL_atarieddi_s.h" #include "SDL_atarieddi_s.h"
#include "SDL_atarimxalloc_c.h" #include "SDL_atarimxalloc_c.h"
#include "SDL_gemvideo.h" #include "SDL_gemvideo.h"
...@@ -65,6 +63,8 @@ static char rcsid = ...@@ -65,6 +63,8 @@ static char rcsid =
/* Defines */ /* Defines */
/*#define DEBUG_VIDEO_GEM 1*/
#define GEM_VID_DRIVER_NAME "gem" #define GEM_VID_DRIVER_NAME "gem"
/* Variables */ /* Variables */
...@@ -97,6 +97,7 @@ static int GEM_ToggleFullScreen(_THIS, int on); ...@@ -97,6 +97,7 @@ static int GEM_ToggleFullScreen(_THIS, int on);
/* Internal functions */ /* Internal functions */
static void GEM_FreeBuffers(_THIS); static void GEM_FreeBuffers(_THIS);
static void GEM_ClearScreen(_THIS); static void GEM_ClearScreen(_THIS);
static void GEM_ClearRect(_THIS, short *rect);
static void GEM_LockScreen(_THIS); static void GEM_LockScreen(_THIS);
static void GEM_UnlockScreen(_THIS); static void GEM_UnlockScreen(_THIS);
static void refresh_window(_THIS, int winhandle, short *rect); static void refresh_window(_THIS, int winhandle, short *rect);
...@@ -139,8 +140,6 @@ static SDL_VideoDevice *GEM_CreateDevice(int devindex) ...@@ -139,8 +140,6 @@ static SDL_VideoDevice *GEM_CreateDevice(int devindex)
} }
memset(device->hidden, 0, (sizeof *device->hidden)); memset(device->hidden, 0, (sizeof *device->hidden));
atari_test_cpu060_present();
/* Set the function pointers */ /* Set the function pointers */
device->VideoInit = GEM_VideoInit; device->VideoInit = GEM_VideoInit;
device->ListModes = GEM_ListModes; device->ListModes = GEM_ListModes;
...@@ -157,7 +156,7 @@ static SDL_VideoDevice *GEM_CreateDevice(int devindex) ...@@ -157,7 +156,7 @@ static SDL_VideoDevice *GEM_CreateDevice(int devindex)
/* Window manager */ /* Window manager */
device->SetCaption = GEM_SetCaption; device->SetCaption = GEM_SetCaption;
device->SetIcon = NULL /*GEM_SetIcon*/; device->SetIcon = GEM_SetIcon;
device->IconifyWindow = GEM_IconifyWindow; device->IconifyWindow = GEM_IconifyWindow;
device->GrabInput = GEM_GrabInput; device->GrabInput = GEM_GrabInput;
...@@ -218,48 +217,26 @@ static void VDI_ReadExtInfo(_THIS, short *work_out) ...@@ -218,48 +217,26 @@ static void VDI_ReadExtInfo(_THIS, short *work_out)
if (work_out[14] & (1<<7)) { if (work_out[14] & (1<<7)) {
/* Little endian */ /* Little endian */
if (work_out[14] & (1<<1)) { if (work_out[14] & (1<<1)) {
/* Falcon */ VDI_FBMASK(1<<13, 31<<3, (3<<14)|7, 31<<8);
VDI_alphamask = 1 << 13;
VDI_redmask = 31 << 3;
VDI_greenmask = (3 << 14) | 7;
VDI_bluemask = 31 << 8;
} else { } else {
/* Others */ VDI_FBMASK(1<<7, 31<<2, (7<<13)|3, 31<<8);
VDI_alphamask = 1 << 7;
VDI_redmask = 31 << 2;
VDI_greenmask = (7 << 13) | 3;
VDI_bluemask = 31 << 8;
} }
} else { } else {
/* Big endian */ /* Big endian */
if (work_out[14] & (1<<1)) { if (work_out[14] & (1<<1)) {
/* Falcon */ VDI_FBMASK(1<<5, 31<<11, 31<<6, 31);
VDI_alphamask = 1 << 5;
VDI_redmask = 31 << 11;
VDI_greenmask = 31 << 6;
VDI_bluemask = 31;
} else { } else {
/* Others */ VDI_FBMASK(1<<15, 31<<10, 31<<5, 31);
VDI_alphamask = 1 << 15;
VDI_redmask = 31 << 10;
VDI_greenmask = 31 << 5;
VDI_bluemask = 31;
} }
} }
break; break;
case 65536UL: case 65536UL:
if (work_out[14] & (1<<7)) { if (work_out[14] & (1<<7)) {
/* Little endian */ /* Little endian */
VDI_alphamask = 0; VDI_FBMASK(0, 31<<3, (7<<13)|7, 31<<8);
VDI_redmask = 31 << 3;
VDI_greenmask = (7 << 13) | 7;
VDI_bluemask = 31 << 8;
} else { } else {
/* Big endian */ /* Big endian */
VDI_alphamask = 0; VDI_FBMASK(0, 31<<11, 63<<5, 31);
VDI_redmask = 31 << 11;
VDI_greenmask = 63 << 5;
VDI_bluemask = 31;
} }
break; break;
case 16777216UL: case 16777216UL:
...@@ -267,32 +244,20 @@ static void VDI_ReadExtInfo(_THIS, short *work_out) ...@@ -267,32 +244,20 @@ static void VDI_ReadExtInfo(_THIS, short *work_out)
/* Little endian */ /* Little endian */
switch(num_bits) { switch(num_bits) {
case 24: case 24:
VDI_alphamask = 0; VDI_FBMASK(0, 255, 255<<8, 255<<16);
VDI_redmask = 255;
VDI_greenmask = 255 << 8;
VDI_bluemask = 255 << 16;
break; break;
case 32: case 32:
VDI_alphamask = 255; VDI_FBMASK(255, 255<<8, 255<<16, 255<<24);
VDI_redmask = 255 << 8;
VDI_greenmask = 255 << 16;
VDI_bluemask = 255 << 24;
break; break;
} }
} else { } else {
/* Big endian */ /* Big endian */
switch(num_bits) { switch(num_bits) {
case 24: case 24:
VDI_alphamask = 0; VDI_FBMASK(0, 255<<16, 255<<8, 255);
VDI_redmask = 255 << 16;
VDI_greenmask = 255 << 8;
VDI_bluemask = 255;
break; break;
case 32: case 32:
VDI_alphamask = 255 << 24; VDI_FBMASK(255<<24, 255<<16, 255<<8, 255);
VDI_redmask = 255 << 16;
VDI_greenmask = 255 << 8;
VDI_bluemask = 255;
break; break;
} }
} }
...@@ -371,13 +336,31 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -371,13 +336,31 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
/* Read version and features */ /* Read version and features */
GEM_version = aes_params.global[0]; GEM_version = aes_global[0];
if (GEM_version >= 0x0400) { if (GEM_version >= 0x0410) {
short ap_gout[4]; short ap_gout[4], errorcode;
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: AES %02x.%02x\n", (GEM_version>>8) & 0xff, GEM_version & 0xff);
#endif
GEM_wfeatures=0; GEM_wfeatures=0;
if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3])==0) { errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]);
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: appl_getinfo() returned 0x%04x\n", errorcode);
#endif
if (errorcode==0) {
GEM_wfeatures=ap_gout[0]; GEM_wfeatures=ap_gout[0];
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: AES wind_*() modes: 0x%04x\n", GEM_wfeatures);
printf("sdl:video:gem: AES window behaviours: 0x%04x\n", ap_gout[3]);
} else {
printf("sdl:video:gem: apgout[]={0x%04x,0x%04x,0x%04x,0x%04x}\n",
ap_gout[0], ap_gout[1], ap_gout[1], ap_gout[3]
);
#endif
} }
} }
...@@ -469,7 +452,10 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -469,7 +452,10 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
VDI_ReadExtInfo(this, work_out); VDI_ReadExtInfo(this, work_out);
if (VDI_screen == NULL) { if (VDI_screen == NULL) {
VDI_pitch = VDI_w * VDI_pixelsize; VDI_pitch = VDI_w * VDI_pixelsize;
VDI_format = VDI_FORMAT_UNKNOWN; VDI_format = VDI_FORMAT_PACK;
if (VDI_bpp <= 8) {
VDI_format = VDI_FORMAT_INTER;
}
VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
} }
...@@ -480,14 +466,6 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -480,14 +466,6 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
this->info.hw_available = 0; this->info.hw_available = 0;
this->info.video_mem = 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 */ /* Determine the screen depth */
/* we change this during the SDL_SetVideoMode implementation... */ /* we change this during the SDL_SetVideoMode implementation... */
vformat->BitsPerPixel = VDI_bpp; vformat->BitsPerPixel = VDI_bpp;
...@@ -496,13 +474,16 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -496,13 +474,16 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
graf_mouse(ARROW, NULL); graf_mouse(ARROW, NULL);
/* Init chunky to planar routine */ /* Init chunky to planar routine */
Atari_C2pInit = Atari_C2pInit8; SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
if (atari_cpu060_avail) {
Atari_C2pConvert = Atari_C2pConvert8_060; /* Setup VDI fill functions */
} else { vsf_color(VDI_handle,0);
Atari_C2pConvert = Atari_C2pConvert8; vsf_interior(VDI_handle,1);
} vsf_perimeter(VDI_handle,0);
Atari_C2pInit();
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: VideoInit(): done\n");
#endif
/* We're done! */ /* We're done! */
return(0); return(0);
...@@ -520,9 +501,14 @@ SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) ...@@ -520,9 +501,14 @@ SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
static void GEM_FreeBuffers(_THIS) static void GEM_FreeBuffers(_THIS)
{ {
/* Release buffer */ /* Release buffer */
if ( GEM_buffer ) { if ( GEM_buffer2 ) {
free( GEM_buffer ); free( GEM_buffer2 );
GEM_buffer=NULL; GEM_buffer2=NULL;
}
if ( GEM_buffer1 ) {
free( GEM_buffer1 );
GEM_buffer1=NULL;
} }
/* Destroy window */ /* Destroy window */
...@@ -533,26 +519,31 @@ static void GEM_FreeBuffers(_THIS) ...@@ -533,26 +519,31 @@ static void GEM_FreeBuffers(_THIS)
} }
} }
static void GEM_ClearScreen(_THIS) static void GEM_ClearRect(_THIS, short *rect)
{ {
short rgb[3]={0,0,0}; short oldrgb[3], 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); vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
vs_color(VDI_handle, vdi_index[0], rgb); 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_color(VDI_handle,0);
vsf_interior(VDI_handle,1); vsf_interior(VDI_handle,1);
vsf_perimeter(VDI_handle,0); vsf_perimeter(VDI_handle,0);
v_bar(VDI_handle,pxy); v_bar(VDI_handle, rect);
vs_color(VDI_handle, vdi_index[0], oldrgb); vs_color(VDI_handle, vdi_index[0], oldrgb);
}
static void GEM_ClearScreen(_THIS)
{
short pxy[4];
v_hide_c(VDI_handle);
pxy[0] = pxy[1] = 0;
pxy[2] = VDI_w - 1;
pxy[3] = VDI_h - 1;
GEM_ClearRect(this, pxy);
v_show_c(VDI_handle, 1); v_show_c(VDI_handle, 1);
} }
...@@ -588,7 +579,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -588,7 +579,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
{ {
int maxwidth, maxheight; int maxwidth, maxheight;
Uint32 modeflags, screensize; Uint32 modeflags, screensize;
SDL_bool use_shadow; SDL_bool use_shadow1, use_shadow2;
GEM_FreeBuffers(this); GEM_FreeBuffers(this);
...@@ -613,38 +604,48 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -613,38 +604,48 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
return(NULL); return(NULL);
} }
/*--- Allocate shadow buffer if needed ---*/ screensize = width * height * VDI_pixelsize;
use_shadow=SDL_FALSE;
if (flags & SDL_FULLSCREEN) { /*--- Allocate shadow buffers if needed, and conversion operations ---*/
if (!VDI_screen) { GEM_bufops=0;
/* No access to real framebuffer, use shadow surface */ use_shadow1=use_shadow2=SDL_FALSE;
use_shadow=SDL_TRUE; if (VDI_screen && (flags & SDL_FULLSCREEN)) {
} else { if (VDI_format==VDI_FORMAT_INTER) {
if (VDI_format==VDI_FORMAT_INTER) { use_shadow1=SDL_TRUE;
/* Real framebuffer, interleaved bitplanes, GEM_bufops = B2S_C2P_1TOS;
use shadow surface */
use_shadow=SDL_TRUE;
} else if (flags & SDL_DOUBLEBUF) {
/* Real framebuffer, double-buffered,
use shadow surface */
use_shadow=SDL_TRUE;
modeflags |= SDL_DOUBLEBUF;
}
} }
} else { } else {
/* Windowed mode, always with shadow surface */ use_shadow1=SDL_TRUE;
use_shadow=SDL_TRUE; if (VDI_format==VDI_FORMAT_PACK) {
GEM_bufops = B2S_VROCPYFM_1TOS;
} else {
use_shadow2=SDL_TRUE;
GEM_bufops = B2S_C2P_1TO2|B2S_VROCPYFM_2TOS;
}
} }
if (use_shadow) { if (use_shadow1) {
screensize = width * height * VDI_pixelsize; GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM);
if (GEM_buffer1==NULL) {
fprintf(stderr,"Unable to allocate shadow buffer\n");
return NULL;
}
memset(GEM_buffer1, 0, screensize);
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: setvideomode(): allocated buffer 1\n");
#endif
}
GEM_buffer = Atari_SysMalloc(screensize, MX_PREFTTRAM); if (use_shadow2) {
if (GEM_buffer==NULL) { GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM);
if (GEM_buffer2==NULL) {
fprintf(stderr,"Unable to allocate shadow buffer\n"); fprintf(stderr,"Unable to allocate shadow buffer\n");
return NULL; return NULL;
} }
memset(GEM_buffer, 0, screensize); memset(GEM_buffer2, 0, screensize);
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: setvideomode(): allocated buffer 2\n");
#endif
} }
/*--- Initialize screen ---*/ /*--- Initialize screen ---*/
...@@ -659,7 +660,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -659,7 +660,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
GEM_ClearScreen(this); GEM_ClearScreen(this);
modeflags |= SDL_FULLSCREEN; modeflags |= SDL_FULLSCREEN;
if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow) { if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow1) {
modeflags |= SDL_HWSURFACE; modeflags |= SDL_HWSURFACE;
} else { } else {
modeflags |= SDL_SWSURFACE; modeflags |= SDL_SWSURFACE;
...@@ -704,8 +705,13 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -704,8 +705,13 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
return NULL; return NULL;
} }
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: handle=%d\n", GEM_handle);
#endif
/* Setup window name */ /* Setup window name */
wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
GEM_refresh_name = SDL_FALSE;
/* Open the window */ /* Open the window */
wind_open(GEM_handle,x2,y2,w2,h2); wind_open(GEM_handle,x2,y2,w2,h2);
...@@ -717,8 +723,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -717,8 +723,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
current->flags = modeflags; current->flags = modeflags;
current->w = width; current->w = width;
current->h = height; current->h = height;
if (use_shadow) { if (use_shadow1) {
current->pixels = GEM_buffer; current->pixels = GEM_buffer1;
current->pitch = width * (VDI_bpp >> 3); current->pitch = width * (VDI_bpp >> 3);
} else { } else {
current->pixels = VDI_screen; current->pixels = VDI_screen;
...@@ -733,7 +739,6 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -733,7 +739,6 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
return(current); return(current);
} }
/* We don't actually allow hardware surfaces other than the main one */
static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface) static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface)
{ {
return -1; return -1;
...@@ -743,7 +748,6 @@ static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface) ...@@ -743,7 +748,6 @@ static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface)
return; return;
} }
/* We need to wait for vertical retrace on page flipped displays */
static int GEM_LockHWSurface(_THIS, SDL_Surface *surface) static int GEM_LockHWSurface(_THIS, SDL_Surface *surface)
{ {
return(0); return(0);
...@@ -757,93 +761,96 @@ static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface) ...@@ -757,93 +761,96 @@ static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface)
static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects) static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects)
{ {
SDL_Surface *surface; SDL_Surface *surface;
MFDB mfdb_src;
short blitcoords[8];
int i; int i;
surface = this->screen; surface = this->screen;
if (VDI_screen) { if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {
if (VDI_format==VDI_FORMAT_INTER) { void *destscr;
void *destscr; int destpitch;
if (GEM_bufops & B2S_C2P_1TOS) {
int destx; int destx;
destscr = VDI_screen; destscr = VDI_screen;
destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
destx = (VDI_w - surface->w) >> 1; destx = (VDI_w - surface->w) >> 1;
destx &= ~15; destx &= ~15;
destscr += destx; destscr += destx;
destpitch = VDI_pitch;
} else {
destscr = GEM_buffer2;
destpitch = surface->pitch;
}
for (i=0;i<numrects;i++) { for (i=0;i<numrects;i++) {
void *source,*destination; void *source,*destination;
int x1,x2; int x1,x2;
x1 = rects[i].x & ~15;
x2 = rects[i].x+rects[i].w;
if (x2 & 15) {
x2 = (x2 | 15) +1;
}
source = surface->pixels;
source += surface->pitch * rects[i].y;
source += x1;
destination = destscr;
destination += VDI_pitch * rects[i].y;
destination += x1;
/* Convert chunky to planar screen */
Atari_C2pConvert(
source,
destination,
x2-x1,
rects[i].h,
SDL_FALSE,
surface->pitch,
VDI_pitch
);
x1 = rects[i].x & ~15;
x2 = rects[i].x+rects[i].w;
if (x2 & 15) {
x2 = (x2 | 15) +1;
} }
return; source = surface->pixels;
} source += surface->pitch * rects[i].y;
source += x1;
if (!(surface->flags & SDL_DOUBLEBUF)) { destination = destscr;
return; destination += destpitch * rects[i].y;
destination += x1;
SDL_Atari_C2pConvert(
source, destination,
x2-x1, rects[i].h,
SDL_FALSE,
surface->pitch, destpitch
);
} }
} }
mfdb_src.fd_addr=surface->pixels; if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {
mfdb_src.fd_w=surface->w; MFDB mfdb_src;
mfdb_src.fd_h=surface->h; short blitcoords[8];
mfdb_src.fd_wdwidth=(surface->w) >> 4;
mfdb_src.fd_stand=0;
mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
mfdb_src.fd_r1=0;
mfdb_src.fd_r2=0;
mfdb_src.fd_r3=0;
for ( i=0; i<numrects; ++i ) { mfdb_src.fd_addr=surface->pixels;
blitcoords[0] = rects[i].x; mfdb_src.fd_w=surface->w;
blitcoords[1] = rects[i].y; mfdb_src.fd_h=surface->h;
blitcoords[2] = blitcoords[0] + rects[i].w - 1; mfdb_src.fd_wdwidth=(surface->w) >> 4;
blitcoords[3] = blitcoords[1] + rects[i].h - 1; mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
mfdb_src.fd_stand=
mfdb_src.fd_r1=
mfdb_src.fd_r2=
mfdb_src.fd_r3= 0;
if (GEM_bufops & B2S_VROCPYFM_2TOS) {
mfdb_src.fd_addr=GEM_buffer2;
}
blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1); for ( i=0; i<numrects; ++i ) {
blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1); blitcoords[0] = rects[i].x;
blitcoords[6] = blitcoords[4] + rects[i].w - 1; blitcoords[1] = rects[i].y;
blitcoords[7] = blitcoords[5] + rects[i].h - 1; blitcoords[2] = blitcoords[0] + rects[i].w - 1;
blitcoords[3] = blitcoords[1] + rects[i].h - 1;
vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1);
blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1);
blitcoords[6] = blitcoords[4] + rects[i].w - 1;
blitcoords[7] = blitcoords[5] + rects[i].h - 1;
vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
}
} }
} }
static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects) static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects)
{ {
short pxy[8], wind_pxy[8]; short pxy[4], wind_pxy[4];
int i; int i;
wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
return;
}
for ( i=0; i<numrects; ++i ) { for ( i=0; i<numrects; ++i ) {
pxy[0] = wind_pxy[0] + rects[i].x; pxy[0] = wind_pxy[0] + rects[i].x;
...@@ -870,60 +877,62 @@ static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects) ...@@ -870,60 +877,62 @@ static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface) static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)
{ {
MFDB mfdb_src; if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {
short blitcoords[8]; void *destscr;
int destpitch;
if (VDI_screen) { if (GEM_bufops & B2S_C2P_1TOS) {
if (VDI_format==VDI_FORMAT_INTER) {
void *destscr;
int destx; int destx;
/* Center on destination screen */
destscr = VDI_screen; destscr = VDI_screen;
destscr += VDI_pitch * ((VDI_h - surface->h) >> 1); destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
destx = (VDI_w - surface->w) >> 1; destx = (VDI_w - surface->w) >> 1;
destx &= ~15; destx &= ~15;
destscr += destx; destscr += destx;
destpitch = VDI_pitch;
} else {
destscr = GEM_buffer2;
destpitch = surface->pitch;
}
/* Convert chunky to planar screen */ SDL_Atari_C2pConvert(
Atari_C2pConvert( surface->pixels, destscr,
surface->pixels, surface->w, surface->h,
destscr, SDL_FALSE,
surface->w, surface->pitch, destpitch
surface->h, );
SDL_FALSE, }
surface->pitch,
VDI_pitch
);
return(0); if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {
} MFDB mfdb_src;
short blitcoords[8];
if (!(surface->flags & SDL_DOUBLEBUF)) { mfdb_src.fd_w=surface->w;
return(0); mfdb_src.fd_h=surface->h;
mfdb_src.fd_wdwidth=(surface->w) >> 4;
mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
mfdb_src.fd_stand=
mfdb_src.fd_r1=
mfdb_src.fd_r2=
mfdb_src.fd_r3= 0;
if (GEM_bufops & B2S_VROCPYFM_1TOS) {
mfdb_src.fd_addr=surface->pixels;
} else {
mfdb_src.fd_addr=GEM_buffer2;
} }
blitcoords[0] = 0;
blitcoords[1] = 0;
blitcoords[2] = surface->w - 1;
blitcoords[3] = surface->h - 1;
blitcoords[4] = (VDI_w - surface->w) >> 1;
blitcoords[5] = (VDI_h - surface->h) >> 1;
blitcoords[6] = blitcoords[4] + surface->w - 1;
blitcoords[7] = blitcoords[5] + surface->h - 1;
vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
} }
mfdb_src.fd_addr=surface->pixels;
mfdb_src.fd_w=surface->w;
mfdb_src.fd_h=surface->h;
mfdb_src.fd_wdwidth=(surface->w) >> 4;
mfdb_src.fd_stand=0;
mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
mfdb_src.fd_r1=0;
mfdb_src.fd_r2=0;
mfdb_src.fd_r3=0;
blitcoords[0] = 0;
blitcoords[1] = 0;
blitcoords[2] = surface->w - 1;
blitcoords[3] = surface->h - 1;
blitcoords[4] = (VDI_w - surface->w) >> 1;
blitcoords[5] = (VDI_h - surface->h) >> 1;
blitcoords[6] = blitcoords[4] + surface->w - 1;
blitcoords[7] = blitcoords[5] + surface->h - 1;
vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
return(0); return(0);
} }
...@@ -954,6 +963,10 @@ static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ...@@ -954,6 +963,10 @@ static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
int i; int i;
SDL_Surface *surface; SDL_Surface *surface;
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: setcolors()\n");
#endif
/* Do not change palette in True Colour */ /* Do not change palette in True Colour */
surface = this->screen; surface = this->screen;
if (surface->format->BitsPerPixel > 8) { if (surface->format->BitsPerPixel > 8) {
...@@ -1044,76 +1057,193 @@ void GEM_wind_redraw(_THIS, int winhandle, short *inside) ...@@ -1044,76 +1057,193 @@ void GEM_wind_redraw(_THIS, int winhandle, short *inside)
v_hide_c(VDI_handle); v_hide_c(VDI_handle);
/* Browse the rectangle list to redraw */ /* Browse the rectangle list to redraw */
wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3]); if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) {
while (todo[2] && todo[3]) { while (todo[2] && todo[3]) {
if (rc_intersect((GRECT *)inside,(GRECT *)todo)) {
todo[2] += todo[0]-1;
todo[3] += todo[1]-1;
refresh_window(this, winhandle, todo);
}
if (rc_intersect((GRECT *)inside,(GRECT *)todo)) { if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) {
todo[2] += todo[0]-1; break;
todo[3] += todo[1]-1; }
refresh_window(this, winhandle, todo);
} }
wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3]);
} }
/* Update finished */ /* Update finished */
wind_update(END_UPDATE); wind_update(END_UPDATE);
v_show_c(VDI_handle,1); v_show_c(VDI_handle,1);
#if DEBUG_VIDEO_GEM
fflush(stdout);
#endif
} }
static void refresh_window(_THIS, int winhandle, short *rect) static void refresh_window(_THIS, int winhandle, short *rect)
{ {
MFDB mfdb_src; MFDB mfdb_src;
short pxy[8], wind_pxy[8]; short pxy[8],wind_pxy[8];
int iconified;
SDL_Surface *surface; SDL_Surface *surface;
int iconified;
surface=this->screen;
/* Is window iconified ? */ /* Is window iconified ? */
iconified = 0; iconified = 0;
if (GEM_wfeatures & (1<<WF_ICONIFY)) { /* if (GEM_wfeatures & (1<<WF_ICONIFY))*/ {
wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); if (wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])!=0) {
iconified = pxy[0]; iconified = wind_pxy[0];
}
}
if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
return;
} }
wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); if (iconified && GEM_icon) {
short icon_rect[4], dst_rect[4];
surface = GEM_icon;
GEM_ClearRect(this, rect);
/* Calculate centered icon(x,y,w,h) relative to window */
icon_rect[0] = (wind_pxy[2]-surface->w)>>1;
icon_rect[1] = (wind_pxy[3]-surface->h)>>1;
icon_rect[2] = surface->w;
icon_rect[3] = surface->h;
/* Calculate redraw rectangle(x,y,w,h) relative to window */
dst_rect[0] = rect[0]-wind_pxy[0];
dst_rect[1] = rect[1]-wind_pxy[1];
dst_rect[2] = rect[2]-rect[0]+1;
dst_rect[3] = rect[3]-rect[1]+1;
/* Does the icon rectangle must be redrawn ? */
if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) {
return;
}
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n",
surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]);
printf("sdl:video:gem: icon(%d,%d,%d,%d)\n",
icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]);
printf("sdl:video:gem: refresh_window(): draw icon\n");
#endif
/* Calculate icon(x1,y1,x2,y2) relative to screen */
icon_rect[0] += wind_pxy[0];
icon_rect[1] += wind_pxy[1];
icon_rect[2] += icon_rect[0]-1;
icon_rect[3] += icon_rect[1]-1;
/* Calculate intersection rectangle to redraw */
pxy[0]=0;
pxy[1]=0;
pxy[2]=surface->w - 1;
pxy[3]=surface->h - 1;
pxy[4]=rect[0];
pxy[5]=rect[1];
pxy[6]=rect[2];
pxy[7]=rect[3];
if (icon_rect[0]>rect[0]) {
pxy[4]=icon_rect[0];
} else if (icon_rect[0]<rect[0]) {
pxy[0]=rect[0]-icon_rect[0];
}
if (icon_rect[1]>rect[1]) {
pxy[5]=icon_rect[1];
} else if (icon_rect[1]<rect[1]) {
pxy[1]=rect[1]-icon_rect[1];
}
if (icon_rect[2]>rect[2]) {
pxy[2]=rect[2]-icon_rect[0];
pxy[6]=rect[2];
} else if (icon_rect[2]<rect[2]) {
pxy[2]=icon_rect[2]-rect[0];
pxy[6]=icon_rect[2];
}
if (icon_rect[3]>rect[3]) {
pxy[3]=rect[3]-icon_rect[1];
pxy[7]=rect[3];
} else if (icon_rect[3]<rect[3]) {
pxy[3]=icon_rect[3]-rect[1];
pxy[7]=icon_rect[3];
}
if (iconified) {
/* Refresh icon */
mfdb_src.fd_addr=surface->pixels; /* Should be icon image */
mfdb_src.fd_w=surface->w;
mfdb_src.fd_h=surface->h;
mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;
mfdb_src.fd_stand=0;
mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
mfdb_src.fd_r1=0;
mfdb_src.fd_r2=0;
mfdb_src.fd_r3=0;
} else { } else {
/* Refresh window */ surface = this->screen;
mfdb_src.fd_addr=surface->pixels;
mfdb_src.fd_w=surface->w; #ifdef DEBUG_VIDEO_GEM
mfdb_src.fd_h=surface->h; printf("sdl:video:gem: refresh_window(): draw frame buffer\n");
mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; #endif
mfdb_src.fd_stand=0;
mfdb_src.fd_nplanes=surface->format->BitsPerPixel; /* Redraw all window content */
mfdb_src.fd_r1=0; pxy[0] = rect[0]-wind_pxy[0];
mfdb_src.fd_r2=0; pxy[1] = rect[1]-wind_pxy[1];
mfdb_src.fd_r3=0; pxy[2] = rect[2]-wind_pxy[0];
pxy[3] = rect[3]-wind_pxy[1];
pxy[4] = rect[0];
pxy[5] = rect[1];
pxy[6] = rect[2];
pxy[7] = rect[3];
}
if (GEM_bufops & B2S_C2P_1TO2) {
void *src, *dest;
int x1,x2;
x1 = (rect[0]-wind_pxy[0]) & ~15;
x2 = rect[2]-wind_pxy[0];
if (x2 & 15) {
x2 = (x2 | 15) +1;
}
src = surface->pixels;
src += surface->pitch * (rect[1]-wind_pxy[1]);
src += x1;
dest = GEM_buffer2;
dest += surface->pitch * (rect[1]-wind_pxy[1]);
dest += x1;
SDL_Atari_C2pConvert(
src, dest,
x2-x1, rect[3]-rect[1]+1,
SDL_FALSE,
surface->pitch, surface->pitch
);
} }
pxy[0] = rect[0] - wind_pxy[0]; mfdb_src.fd_addr=surface->pixels;
pxy[1] = rect[1] - wind_pxy[1]; mfdb_src.fd_w=surface->w;
pxy[2] = pxy[0] + rect[2] - rect[0]; mfdb_src.fd_h=surface->h;
pxy[3] = pxy[1] + rect[3] - rect[1]; mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;
mfdb_src.fd_stand=
mfdb_src.fd_r1=
mfdb_src.fd_r2=
mfdb_src.fd_r3= 0;
if (GEM_bufops & B2S_VROCPYFM_2TOS) {
mfdb_src.fd_addr=GEM_buffer2;
}
pxy[4] = rect[0]; #ifdef DEBUG_VIDEO_GEM
pxy[5] = rect[1]; printf("sdl:video:gem: redraw (%d,%d,%d,%d) to (%d,%d,%d,%d)\n",
pxy[6] = rect[2]; pxy[0],pxy[1],pxy[2],pxy[3],
pxy[7] = rect[3]; pxy[4],pxy[5],pxy[6],pxy[7]
);
#endif
vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb);
} }
...@@ -39,37 +39,49 @@ void GEM_wind_redraw(_THIS, int winhandle, short *inside); ...@@ -39,37 +39,49 @@ void GEM_wind_redraw(_THIS, int winhandle, short *inside);
/* Private display data */ /* Private display data */
#define B2S_C2P_1TO2 (1<<0) /* C2P convert buffer 1 to buffer 2 */
#define B2S_C2P_1TOS (1<<1) /* C2P convert buffer 1 to screen */
#define B2S_VROCPYFM_1TOS (1<<2) /* vro_cpyfm() buffer 1 to screen */
#define B2S_VROCPYFM_2TOS (1<<3) /* vro_cpyfm() buffer 2 to screen */
#define SDL_NUMMODES 1 /* Fullscreen */ #define SDL_NUMMODES 1 /* Fullscreen */
struct SDL_PrivateVideoData { struct SDL_PrivateVideoData {
Uint16 buf2scr_ops; /* Operations to get buffer to screen */
void *buffer1; /* Our shadow buffers */
void *buffer2;
/* VDI infos */ /* VDI infos */
short vdi_handle; /* VDI handle */ short vdi_handle; /* VDI handle */
short full_w, full_h; /* Fullscreen size */ short full_w, full_h; /* Fullscreen size */
int bpp; /* Colour depth */ short bpp; /* Colour depth */
int pixelsize; /* Bytes per pixel */ short pixelsize; /* Bytes per pixel */
Uint16 old_numcolors; /* Number of colors in saved palette */ short old_numcolors; /* Number of colors in saved palette */
Uint16 old_palette[256][3]; /* Saved current palette */
Uint16 pitch; /* Line length */ Uint16 pitch; /* Line length */
int format; /* Screen format */ Uint16 format; /* Screen format */
void *screen; /* Screen address */ void *screen; /* Screen address */
Uint32 red, green, blue, alpha; /* Screen components */ Uint32 red, green, blue, alpha; /* Screen components */
Uint32 screensize; Uint32 screensize;
MFDB src_mfdb, dst_mfdb; /* VDI MFDB for bitblt */
short blit_coords[8]; /* Coordinates for bitblt */ short blit_coords[8]; /* Coordinates for bitblt */
MFDB src_mfdb, dst_mfdb; /* VDI MFDB for bitblt */
Uint16 old_palette[256][3]; /* Saved current palette */
/* GEM infos */ /* GEM infos */
short desk_x, desk_y; /* Desktop properties */ short desk_x, desk_y; /* Desktop properties */
short desk_w, desk_h; short desk_w, desk_h;
short win_handle; /* Our window handle */ short win_handle; /* Our window handle */
void *buffer; /* Our shadow buffer */
int window_type; /* Window type */ int window_type; /* Window type */
const char *title_name; /* Window title */ const char *title_name; /* Window title */
const char *icon_name; /* Icon title */ const char *icon_name; /* Icon title */
short version; /* AES version */ short version; /* AES version */
short wfeatures; /* AES window features */ short wfeatures; /* AES window features */
SDL_bool refresh_name; /* Change window title ? */
SDL_bool window_fulled; /* Window maximized ? */ SDL_bool window_fulled; /* Window maximized ? */
SDL_bool mouse_relative; /* Report relative mouse movement */ SDL_bool mouse_relative; /* Report relative mouse movement */
SDL_bool locked; /* AES locked for fullscreen ? */ SDL_bool locked; /* AES locked for fullscreen ? */
short message[8]; /* To self-send an AES message */
SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */ SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */
SDL_Surface *icon; /* The icon */
}; };
/* Hidden structure -> variables names */ /* Hidden structure -> variables names */
...@@ -97,15 +109,66 @@ struct SDL_PrivateVideoData { ...@@ -97,15 +109,66 @@ struct SDL_PrivateVideoData {
#define GEM_desk_w (this->hidden->desk_w) #define GEM_desk_w (this->hidden->desk_w)
#define GEM_desk_h (this->hidden->desk_h) #define GEM_desk_h (this->hidden->desk_h)
#define GEM_handle (this->hidden->win_handle) #define GEM_handle (this->hidden->win_handle)
#define GEM_buffer (this->hidden->buffer)
#define GEM_win_type (this->hidden->window_type) #define GEM_win_type (this->hidden->window_type)
#define GEM_title_name (this->hidden->title_name) #define GEM_title_name (this->hidden->title_name)
#define GEM_icon_name (this->hidden->icon_name) #define GEM_icon_name (this->hidden->icon_name)
#define GEM_refresh_name (this->hidden->refresh_name)
#define GEM_version (this->hidden->version) #define GEM_version (this->hidden->version)
#define GEM_wfeatures (this->hidden->wfeatures) #define GEM_wfeatures (this->hidden->wfeatures)
#define GEM_win_fulled (this->hidden->window_fulled) #define GEM_win_fulled (this->hidden->window_fulled)
#define GEM_mouse_relative (this->hidden->mouse_relative) #define GEM_mouse_relative (this->hidden->mouse_relative)
#define GEM_locked (this->hidden->locked) #define GEM_locked (this->hidden->locked)
#define GEM_message (this->hidden->message)
#define SDL_modelist (this->hidden->SDL_modelist) #define SDL_modelist (this->hidden->SDL_modelist)
#define GEM_icon (this->hidden->icon)
#define GEM_buffer1 (this->hidden->buffer1)
#define GEM_buffer2 (this->hidden->buffer2)
#define GEM_bufops (this->hidden->buf2scr_ops)
#define VDI_FBMASK(amask, rmask, gmask, bmask) \
VDI_alphamask = (amask); \
VDI_redmask = (rmask); \
VDI_greenmask = (gmask); \
VDI_bluemask = (bmask);
/*
Possible buffer to screen operations:
TC: 8 (chunky),15,16,24,32 bpp
8I: 8 bpp planes
FB: screen framebuffer address available
FS: fullscreen
TC, FB, FS:
- draw to screen
8I, FB, FS:
- draw to buffer 1
- C2P from buffer 1 to screen
TC, !FB, FS:
- draw to buffer 1
- vro_cpyfm() from buffer 1 to screen
8I, !FB, FS:
- draw to buffer 1
- C2P from buffer 1 to buffer 2
- vro_cpyfm() from buffer 2 to screen
TC, FB, !FS:
- draw to buffer 1
- vro_cpyfm() from buffer 1 to screen
8I, FB, !FS:
- draw to buffer 1
- C2P from buffer 1 to buffer 2
- vro_cpyfm() from buffer 2 to screen
TC, !FB, !FS:
- draw to buffer 1
- vro_cpyfm() from buffer 1 to screen
8I, !FB, !FS:
- draw to buffer 1
- C2P from buffer 1 to buffer 2
- vro_cpyfm() from buffer 2 to screen
*/
#endif /* _SDL_gemvideo_h */ #endif /* _SDL_gemvideo_h */
...@@ -26,11 +26,11 @@ static char rcsid = ...@@ -26,11 +26,11 @@ static char rcsid =
#endif #endif
/* /*
* GEM SDL video driver implementation GEM SDL video driver
* Window manager functions Window manager functions
*
* Patrice Mandin Patrice Mandin
*/ */
/* Mint includes */ /* Mint includes */
#include <gem.h> #include <gem.h>
...@@ -39,6 +39,8 @@ static char rcsid = ...@@ -39,6 +39,8 @@ static char rcsid =
/* Defines */ /* Defines */
#define DEBUG_VIDEO_GEM 0
#define ICONWIDTH 64 #define ICONWIDTH 64
#define ICONHEIGHT 64 #define ICONHEIGHT 64
...@@ -46,65 +48,77 @@ static char rcsid = ...@@ -46,65 +48,77 @@ static char rcsid =
void GEM_SetCaption(_THIS, const char *title, const char *icon) void GEM_SetCaption(_THIS, const char *title, const char *icon)
{ {
short parm[4]; if (title) {
const char *new_name;
new_name = NULL;
if (title)
GEM_title_name = title; GEM_title_name = title;
GEM_refresh_name = SDL_TRUE;
if (icon)
GEM_icon_name = icon;
/* Is window iconified ? */
parm[0]=0;
if (GEM_wfeatures & (1<<WF_ICONIFY))
wind_get(GEM_handle, WF_ICONIFY, &parm[0], &parm[1], &parm[2], &parm[3]);
if (parm[0]==0) {
/* Change window name */
if (title)
new_name = title;
} else {
/* Change icon name */
if (icon)
new_name = icon;
} }
parm[0]= ((unsigned long) new_name)>>16; if (icon) {
parm[1]= ((unsigned long) new_name) & 65535; GEM_icon_name = icon;
GEM_refresh_name = SDL_TRUE;
if (new_name) {
wind_set(GEM_handle, WF_NAME, parm[0], parm[1], 0, 0);
} }
} }
void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
{ {
if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) SDL_Surface *sicon;
SDL_Rect bounds;
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: SetIcon(0x%08x)\n", (long) icon);
#endif
#if 0
if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) {
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: AES can not iconify windows\n");
#endif
return; return;
}
#endif
if (icon == NULL) {
return;
}
/* Convert icon to the screen format */
sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0);
if ( sicon == NULL ) {
return;
}
bounds.x = 0;
bounds.y = 0;
bounds.w = icon->w;
bounds.h = icon->h;
if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) {
SDL_FreeSurface(sicon);
return;
}
/* Todo */ GEM_icon = sicon;
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: SetIcon(): done\n");
#endif
} }
int GEM_IconifyWindow(_THIS) int GEM_IconifyWindow(_THIS)
{ {
short message[8];
if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) if ((GEM_wfeatures & (1<<WF_ICONIFY))==0)
return 0; return 0;
message[0] = WM_ICONIFY; GEM_message[0] = WM_ICONIFY;
message[1] = gl_apid; GEM_message[1] = gl_apid;
message[2] = 0; GEM_message[2] = 0;
message[3] = GEM_handle; GEM_message[3] = GEM_handle;
message[4] = 0; GEM_message[4] = 0;
message[5] = GEM_desk_h-ICONHEIGHT; GEM_message[5] = GEM_desk_h-ICONHEIGHT;
message[6] = ICONWIDTH; GEM_message[6] = ICONWIDTH;
message[7] = ICONHEIGHT; GEM_message[7] = ICONHEIGHT;
appl_write(gl_apid, sizeof(message), message); appl_write(gl_apid, sizeof(GEM_message), GEM_message);
return 1; return 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment