*** empty log message ***
authorSam Lantinga <slouken@libsdl.org>
Tue, 26 Mar 2002 17:37:31 +0000
changeset 319189a6a3416c7
parent 318 0910a3034576
child 320 66f815c147ed
*** empty log message ***
README.MiNT
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemmouse.c
src/video/gem/SDL_gemmouse_c.h
src/video/gem/SDL_gemvideo.c
src/video/xbios/SDL_xbios.c
     1.1 --- a/README.MiNT	Sun Mar 24 21:44:06 2002 +0000
     1.2 +++ b/README.MiNT	Tue Mar 26 17:37:31 2002 +0000
     1.3 @@ -45,7 +45,7 @@
     1.4  ==============================================================================
     1.5  IV.  What is supported:
     1.6  
     1.7 -Keyboard (GEMDOS, BIOS, Ikbd)
     1.8 +Keyboard (GEMDOS, BIOS, GEM, Ikbd)
     1.9  Mouse (XBIOS, GEM, Ikbd)
    1.10  Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
    1.11  Timer (VBL vector)
    1.12 @@ -61,7 +61,10 @@
    1.13  xbios	ikbd	ikbd	vbl	ikbd	hardware
    1.14  xbios	gemdos	xbios	vbl	xbios	hardware
    1.15  xbios	bios	xbios	vbl	xbios	hardware
    1.16 -gem	gem	gem	vbl	xbios	hardware
    1.17 +gem	gem	gem(*)	vbl	xbios	hardware
    1.18 +
    1.19 +(*) GEM does not report relative mouse motion, so xbios mouse driver is used
    1.20 +to report this type event.
    1.21  
    1.22  ==============================================================================
    1.23  V.  Environment variables:
    1.24 @@ -108,6 +111,48 @@
    1.25  	Lightpen and analog paddle are 2 buttons, 2 axis controllers. The 2
    1.26  	buttons are those affected to 1 button joysticks on the same port.
    1.27  
    1.28 +==============================================================================
    1.29 +VI.  More informations about drivers:
    1.30 +
    1.31 +Xbios video:
    1.32 +	Video chip is detected using the _VDO cookie.
    1.33 +	Screen enhancers are not supported, but could be if you know how to
    1.34 +	use them.
    1.35 +
    1.36 +	ST, STE, Mega ST, Mega STE:
    1.37 +		320x200x4 bits, shades of grey, available only for the purpose
    1.38 +		of testing SDL.
    1.39 +	TT:
    1.40 +		320x480x8 and 320x240x8 (software double-lined mode).
    1.41 +	Falcon:
    1.42 +		All modes supported by the current monitor (RVB or VGA).
    1.43 +	Clones and any machine with monochrome monitor:
    1.44 +		Not supported.
    1.45 +
    1.46 +Gem video:
    1.47 +	Automatically used if xbios not available.
    1.48 +
    1.49 +	All machines:
    1.50 +		Only the current resolution, if 8 bits or higher depth.
    1.51 +
    1.52 +IKBD keyboard, mouse and joystick driver:
    1.53 +	Available if _MCH cookie is ST, Mega ST, STE, Mega STE, TT or Falcon.
    1.54 +
    1.55 +	Hades has an IKBD, but xbios is not available for video, so IKBD
    1.56 +	driver is disabled.
    1.57 +
    1.58 +Gemdos and bios keyboard driver:
    1.59 +	Available on all machines.
    1.60 +
    1.61 +Mouse and joystick xbios driver:
    1.62 +	Available on all machines (I think).
    1.63 +
    1.64 +Joypad driver:
    1.65 +	Available if _MCH cookie is STE or Falcon.
    1.66 +
    1.67 +VBL timer driver:
    1.68 +	Available all machines (I think).
    1.69 +
    1.70  -- 
    1.71  Patrice Mandin <pmandin@caramail.com>
    1.72  http://membres.lycos.fr/pmandin/
     2.1 --- a/src/video/gem/SDL_gemevents.c	Sun Mar 24 21:44:06 2002 +0000
     2.2 +++ b/src/video/gem/SDL_gemevents.c	Tue Mar 26 17:37:31 2002 +0000
     2.3 @@ -43,7 +43,8 @@
     2.4  #include "SDL_events_c.h"
     2.5  #include "SDL_gemvideo.h"
     2.6  #include "SDL_gemevents_c.h"
     2.7 -#include "../ataricommon/SDL_atarikeys.h"	/* for keyboard scancodes */
     2.8 +#include "SDL_atarikeys.h"	/* for keyboard scancodes */
     2.9 +#include "SDL_xbiosinterrupt_s.h"
    2.10  
    2.11  /* Defines */
    2.12  
    2.13 @@ -55,8 +56,6 @@
    2.14  static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
    2.15  static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS];
    2.16  
    2.17 -static short prevmousex, prevmousey, prevmouseb;
    2.18 -
    2.19  /* The translation tables from a console scancode to a SDL keysym */
    2.20  static SDLKey keymap[ATARIBIOS_MAXKEYS];
    2.21  
    2.22 @@ -65,7 +64,7 @@
    2.23  static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
    2.24  static int do_messages(_THIS, short *message);
    2.25  static void do_keyboard(short kc, short ks);
    2.26 -static void do_mouse(_THIS, short mx, short my, short mb);
    2.27 +static void do_mouse(_THIS, short mx, short my, short mb, short ks);
    2.28  
    2.29  /* Functions */
    2.30  
    2.31 @@ -124,22 +123,23 @@
    2.32  	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    2.33  
    2.34  	/* Mouse init */
    2.35 -	prevmousex = prevmousey = prevmouseb = 0;
    2.36  	GEM_mouse_relative = SDL_FALSE;
    2.37  }
    2.38  
    2.39  void GEM_PumpEvents(_THIS)
    2.40  {
    2.41 -	short mx, my, mb, dummy;
    2.42 +	short mousex, mousey, mouseb, dummy;
    2.43 +	short kstate, prevkc, prevks;
    2.44  	int i;
    2.45  	SDL_keysym	keysym;
    2.46  
    2.47  	memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
    2.48 +	prevkc = prevks = 0;
    2.49  	
    2.50  	for (;;)
    2.51  	{
    2.52  		int quit, resultat;
    2.53 -		short buffer[8], kc, ks;
    2.54 +		short buffer[8], kc;
    2.55  
    2.56  		quit = 0;
    2.57  
    2.58 @@ -150,7 +150,7 @@
    2.59  			0,0,0,0,0,
    2.60  			buffer,
    2.61  			10,
    2.62 -			&dummy,&dummy,&dummy,&ks,&kc,&dummy
    2.63 +			&dummy,&dummy,&dummy,&kstate,&kc,&dummy
    2.64  		);
    2.65  
    2.66  		/* Message event ? */
    2.67 @@ -158,10 +158,14 @@
    2.68  			quit = do_messages(this, buffer);
    2.69  
    2.70  		/* Keyboard event ? */
    2.71 -		if (resultat & MU_KEYBD)
    2.72 -			do_keyboard(kc,ks);
    2.73 -		else
    2.74 -			do_keyboard(0,0);
    2.75 +		if (resultat & MU_KEYBD) {
    2.76 +			if ((prevkc != kc) || (prevks != kstate)) {
    2.77 +				do_keyboard(kc,kstate);
    2.78 +			} else {
    2.79 +				/* Avoid looping, if repeating same key */
    2.80 +				break;
    2.81 +			}
    2.82 +		}
    2.83  
    2.84  		/* Timer event ? */
    2.85  		if ((resultat & MU_TIMER) || quit)
    2.86 @@ -169,10 +173,10 @@
    2.87  	}
    2.88  
    2.89  	/* Update mouse */
    2.90 -	graf_mkstate(&mx, &my, &mb, &dummy);
    2.91 -	do_mouse(this, mx, my, mb);
    2.92 +	graf_mkstate(&mousex, &mousey, &mouseb, &kstate);
    2.93 +	do_mouse(this, mousex, mousey, mouseb, kstate);
    2.94  
    2.95 -	/* Now generates keyboard events */
    2.96 +	/* Now generate keyboard events */
    2.97  	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
    2.98  		/* Key pressed ? */
    2.99  		if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
   2.100 @@ -259,7 +263,6 @@
   2.101  static void do_keyboard(short kc, short ks)
   2.102  {
   2.103  	int			scancode, asciicode;
   2.104 -	short		dummy;
   2.105  
   2.106  	if (kc) {
   2.107  		scancode=(kc>>8) & 127;
   2.108 @@ -269,9 +272,6 @@
   2.109  		gem_currentascii[scancode]=asciicode;
   2.110  	}
   2.111  
   2.112 -	if (!ks)
   2.113 -		graf_mkstate(&dummy, &dummy, &dummy, &ks);
   2.114 -
   2.115  	/* Read special keys */
   2.116  	if (ks & K_RSHIFT)
   2.117  		gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
   2.118 @@ -283,16 +283,15 @@
   2.119  		gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
   2.120  }
   2.121  
   2.122 -static void do_mouse(_THIS, short mx, short my, short mb)
   2.123 +static void do_mouse(_THIS, short mx, short my, short mb, short ks)
   2.124  {
   2.125 +	static short prevmousex=0, prevmousey=0, prevmouseb=0;
   2.126 +
   2.127  	/* Mouse motion ? */
   2.128  	if ((prevmousex!=mx) || (prevmousey!=my)) {
   2.129  		if (GEM_mouse_relative) {
   2.130 -			short wind_pxy[8];
   2.131 -
   2.132 -			wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]);
   2.133 -
   2.134 -			SDL_PrivateMouseMotion(0, 1, mx-wind_pxy[0], my-wind_pxy[1]);
   2.135 +			SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
   2.136 +			SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
   2.137  		} else {
   2.138  			SDL_PrivateMouseMotion(0, 1, mx, my);
   2.139  		}
   2.140 @@ -304,19 +303,29 @@
   2.141  	if (prevmouseb!=mb) {
   2.142  		int i;
   2.143  
   2.144 -		for (i=0;i<3;i++) {
   2.145 +		for (i=0;i<2;i++) {
   2.146  			int curbutton, prevbutton;
   2.147  		
   2.148  			curbutton = mb & (1<<i);
   2.149  			prevbutton = prevmouseb & (1<<i);
   2.150  		
   2.151 -			if (curbutton & !prevbutton) {
   2.152 -				SDL_PrivateMouseButton(SDL_PRESSED, i, 0, 0);
   2.153 +			if (curbutton && !prevbutton) {
   2.154 +				SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0);
   2.155  			}
   2.156 -			if (!curbutton & prevbutton) {
   2.157 -				SDL_PrivateMouseButton(SDL_RELEASED, i, 0, 0);
   2.158 +			if (!curbutton && prevbutton) {
   2.159 +				SDL_PrivateMouseButton(SDL_RELEASED, i+1, 0, 0);
   2.160  			}
   2.161  		}
   2.162  		prevmouseb = mb;
   2.163  	}
   2.164 +
   2.165 +	/* Read special keys */
   2.166 +	if (ks & K_RSHIFT)
   2.167 +		gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
   2.168 +	if (ks & K_LSHIFT)
   2.169 +		gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF;
   2.170 +	if (ks & K_CTRL)
   2.171 +		gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF;
   2.172 +	if (ks & K_ALT)
   2.173 +		gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
   2.174  }
     3.1 --- a/src/video/gem/SDL_gemmouse.c	Sun Mar 24 21:44:06 2002 +0000
     3.2 +++ b/src/video/gem/SDL_gemmouse.c	Tue Mar 26 17:37:31 2002 +0000
     3.3 @@ -136,21 +136,26 @@
     3.4  	return 1;
     3.5  }
     3.6  
     3.7 +#if 0
     3.8  void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
     3.9  {
    3.10 +	/* This seems to work only on AES 3.4 (Falcon) */
    3.11 +
    3.12  	EVNTREC	warpevent;
    3.13  	
    3.14  	warpevent.ap_event = APPEVNT_MOUSE; 
    3.15 -	warpevent.ap_value = (y << 16) | x;
    3.16 +	warpevent.ap_value = (x << 16) | y;
    3.17  
    3.18  	appl_tplay(&warpevent, 1, 1000);
    3.19  }
    3.20 +#endif
    3.21  
    3.22  void GEM_CheckMouseMode(_THIS)
    3.23  {
    3.24  	/* If the mouse is hidden and input is grabbed, we use relative mode */
    3.25  	if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
    3.26 -		(this->input_grab != SDL_GRAB_OFF) ) {
    3.27 +		(this->input_grab != SDL_GRAB_OFF) &&
    3.28 +             (SDL_GetAppState() & SDL_APPACTIVE) ) {
    3.29  		GEM_mouse_relative = SDL_TRUE;
    3.30  	} else {
    3.31  		GEM_mouse_relative = SDL_FALSE;
     4.1 --- a/src/video/gem/SDL_gemmouse_c.h	Sun Mar 24 21:44:06 2002 +0000
     4.2 +++ b/src/video/gem/SDL_gemmouse_c.h	Tue Mar 26 17:37:31 2002 +0000
     4.3 @@ -32,6 +32,7 @@
     4.4  extern WMcursor *GEM_CreateWMCursor(_THIS,
     4.5  		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
     4.6  extern int GEM_ShowWMCursor(_THIS, WMcursor *cursor);
     4.7 +#if 0
     4.8  extern void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
     4.9 -extern void GEM_CheckMouseModeNoLock(_THIS);
    4.10 +#endif
    4.11  extern void GEM_CheckMouseMode(_THIS);
     5.1 --- a/src/video/gem/SDL_gemvideo.c	Sun Mar 24 21:44:06 2002 +0000
     5.2 +++ b/src/video/gem/SDL_gemvideo.c	Tue Mar 26 17:37:31 2002 +0000
     5.3 @@ -51,6 +51,7 @@
     5.4  #include "SDL_sysvideo.h"
     5.5  #include "SDL_pixels_c.h"
     5.6  #include "SDL_events_c.h"
     5.7 +#include "SDL_cursor_c.h"
     5.8  
     5.9  #include "SDL_ataric2p_s.h"
    5.10  #include "SDL_ataric2p060_c.h"
    5.11 @@ -95,6 +96,9 @@
    5.12  
    5.13  /* Internal functions */
    5.14  static void GEM_FreeBuffers(_THIS);
    5.15 +static void GEM_ClearScreen(_THIS);
    5.16 +static void GEM_LockScreen(_THIS);
    5.17 +static void GEM_UnlockScreen(_THIS);
    5.18  static void refresh_window(_THIS, int winhandle, short *rect);
    5.19  
    5.20  /* GEM driver bootstrap functions */
    5.21 @@ -174,11 +178,11 @@
    5.22  	device->FreeWMCursor = GEM_FreeWMCursor;
    5.23  	device->CreateWMCursor = GEM_CreateWMCursor;
    5.24  	device->ShowWMCursor = GEM_ShowWMCursor;
    5.25 -	device->WarpWMCursor = GEM_WarpWMCursor;
    5.26 +	device->WarpWMCursor = NULL /*GEM_WarpWMCursor*/;
    5.27  	device->CheckMouseMode = GEM_CheckMouseMode;
    5.28  
    5.29 -	/* Joystick */
    5.30 -	SDL_AtariXbios_InstallVectors(ATARI_XBIOS_JOYSTICKEVENTS);
    5.31 +	/* Joystick + Mouse relative motion */
    5.32 +	SDL_AtariXbios_InstallVectors(ATARI_XBIOS_MOUSEEVENTS|ATARI_XBIOS_JOYSTICKEVENTS);
    5.33  
    5.34  	device->free = GEM_DeleteDevice;
    5.35  
    5.36 @@ -314,7 +318,7 @@
    5.37  				tmp_p = (Uint16 *)&work_out[16];
    5.38  
    5.39  				for (i=0;i<256;i++) {
    5.40 -					vdi_index[i] = *tmp_p++;
    5.41 +					vdi_index[*tmp_p++] = i;
    5.42  				}
    5.43  			}
    5.44  			break;
    5.45 @@ -352,11 +356,11 @@
    5.46  						}
    5.47  					}
    5.48  				}
    5.49 +			}
    5.50  
    5.51 -				/* Remove lower green bits for Intel endian screen */
    5.52 -				if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
    5.53 -					VDI_greenmask &= ~(7<<13);
    5.54 -				}
    5.55 +			/* Remove lower green bits for Intel endian screen */
    5.56 +			if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
    5.57 +				VDI_greenmask &= ~(7<<13);
    5.58  			}
    5.59  			break;
    5.60  		case VDI_CLUT_NONE:
    5.61 @@ -474,7 +478,7 @@
    5.62  	VDI_screen = NULL;
    5.63  	VDI_ReadExtInfo(this, work_out);
    5.64  	if (VDI_screen == NULL) {
    5.65 -		VDI_pitch = VDI_w * ((VDI_bpp)>>3);
    5.66 +		VDI_pitch = VDI_w * VDI_pixelsize;
    5.67  		VDI_format = VDI_FORMAT_UNKNOWN;
    5.68  		VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
    5.69  	}
    5.70 @@ -539,6 +543,56 @@
    5.71  	}
    5.72  }
    5.73  
    5.74 +static void GEM_ClearScreen(_THIS)
    5.75 +{
    5.76 +	short rgb[3]={0,0,0};
    5.77 +	short oldrgb[3];
    5.78 +	short pxy[4];
    5.79 +
    5.80 +	v_hide_c(VDI_handle);
    5.81 +
    5.82 +	vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
    5.83 +	vs_color(VDI_handle, vdi_index[0], rgb);
    5.84 +
    5.85 +	pxy[0] = pxy[1] = 0;
    5.86 +	pxy[2] = VDI_w - 1;
    5.87 +	pxy[3] = VDI_h - 1;
    5.88 +	vsf_color(VDI_handle,0);
    5.89 +	vsf_interior(VDI_handle,1);
    5.90 +	vsf_perimeter(VDI_handle,0);
    5.91 +	v_bar(VDI_handle,pxy);
    5.92 +
    5.93 +	vs_color(VDI_handle, vdi_index[0], oldrgb);
    5.94 +
    5.95 +	v_show_c(VDI_handle, 1);
    5.96 +}
    5.97 +
    5.98 +static void GEM_LockScreen(_THIS)
    5.99 +{
   5.100 +	if (!GEM_locked) {
   5.101 +		/* Reserve memory space, used to be sure of compatibility */
   5.102 +		form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h);
   5.103 +		/* Lock AES */
   5.104 +		wind_update(BEG_UPDATE);
   5.105 +		wind_update(BEG_MCTRL);
   5.106 +
   5.107 +		GEM_locked=SDL_TRUE;
   5.108 +	}
   5.109 +}
   5.110 +
   5.111 +static void GEM_UnlockScreen(_THIS)
   5.112 +{
   5.113 +	if (GEM_locked) {
   5.114 +		/* Restore screen memory, and send REDRAW to all apps */
   5.115 +		form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h);
   5.116 +		/* Unlock AES */
   5.117 +		wind_update(END_MCTRL);
   5.118 +		wind_update(END_UPDATE);
   5.119 +
   5.120 +		GEM_locked=SDL_FALSE;
   5.121 +	}
   5.122 +}
   5.123 +
   5.124  SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
   5.125  				int width, int height, int bpp, Uint32 flags)
   5.126  {
   5.127 @@ -574,11 +628,22 @@
   5.128  	use_shadow=SDL_FALSE;
   5.129  	if (flags & SDL_FULLSCREEN) {
   5.130  		if (!VDI_screen) {
   5.131 +			/* No access to real framebuffer, use shadow surface */
   5.132  			use_shadow=SDL_TRUE;
   5.133 -		} else if (VDI_format==VDI_FORMAT_INTER) {
   5.134 -			use_shadow=SDL_TRUE;
   5.135 +		} else {
   5.136 +			if (VDI_format==VDI_FORMAT_INTER) {
   5.137 +				/* Real framebuffer, interleaved bitplanes,
   5.138 +				  use shadow surface */
   5.139 +				use_shadow=SDL_TRUE;
   5.140 +			} else if (flags & SDL_DOUBLEBUF) {
   5.141 +				/* Real framebuffer, double-buffered,
   5.142 +				  use shadow surface */
   5.143 +				use_shadow=SDL_TRUE;
   5.144 +				modeflags |= SDL_DOUBLEBUF;
   5.145 +			}
   5.146  		}
   5.147  	} else {
   5.148 +		/* Windowed mode, always with shadow surface */
   5.149  		use_shadow=SDL_TRUE;
   5.150  	}
   5.151  
   5.152 @@ -595,30 +660,12 @@
   5.153  
   5.154  	/*--- Initialize screen ---*/
   5.155  	if (flags & SDL_FULLSCREEN) {
   5.156 -		short rgb[3]={0,0,0};
   5.157 -		short pxy[4];
   5.158 +		GEM_LockScreen(this);
   5.159  
   5.160 -		if (!GEM_locked) {
   5.161 -			/* Reserve memory space, used to be sure of compatibility */
   5.162 -			form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h);
   5.163 -			/* Lock AES */
   5.164 -			while (!wind_update(BEG_UPDATE|BEG_MCTRL));
   5.165 -
   5.166 -			GEM_locked=SDL_TRUE;
   5.167 -		}
   5.168 -
   5.169 -		/* Clear screen */
   5.170 -		pxy[0] = pxy[1] = 0;
   5.171 -		pxy[2] = VDI_w - 1;
   5.172 -		pxy[3] = VDI_h - 1;
   5.173 -		vs_color(VDI_handle, vdi_index[0], rgb);
   5.174 -		vsf_color(VDI_handle,0);
   5.175 -		vsf_interior(VDI_handle,1);
   5.176 -		vsf_perimeter(VDI_handle,0);
   5.177 -		v_bar(VDI_handle,pxy);
   5.178 +		GEM_ClearScreen(this);
   5.179  
   5.180  		modeflags |= SDL_FULLSCREEN;
   5.181 -		if (VDI_screen && (VDI_format==VDI_FORMAT_PACK)) {
   5.182 +		if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow) {
   5.183  			modeflags |= SDL_HWSURFACE;
   5.184  		} else {
   5.185  			modeflags |= SDL_SWSURFACE;
   5.186 @@ -627,13 +674,7 @@
   5.187  		int posx,posy;
   5.188  		short x2,y2,w2,h2;
   5.189  
   5.190 -		if (GEM_locked) {
   5.191 -			/* Restore screen memory, and send REDRAW to all apps */
   5.192 -			form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h);
   5.193 -			/* Unlock AES */
   5.194 -			wind_update(END_UPDATE|END_MCTRL);
   5.195 -			GEM_locked=SDL_FALSE;
   5.196 -		}
   5.197 +		GEM_UnlockScreen(this);
   5.198  
   5.199  		/* Center our window */
   5.200  		posx = GEM_desk_x;
   5.201 @@ -722,6 +763,9 @@
   5.202  static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects)
   5.203  {
   5.204  	SDL_Surface *surface;
   5.205 +	MFDB mfdb_src;
   5.206 +	short blitcoords[8];
   5.207 +	int i;
   5.208  
   5.209  	surface = this->screen;
   5.210  
   5.211 @@ -734,47 +778,69 @@
   5.212  			destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
   5.213  			destx = (VDI_w - surface->w) >> 1;
   5.214  			destx &= ~15;
   5.215 -			destscr += VDI_pixelsize * destx;
   5.216 +			destscr += destx;
   5.217  
   5.218 -			/* Convert chunky to planar screen */
   5.219 -			Atari_C2pConvert(
   5.220 -				surface->pixels,
   5.221 -				destscr,
   5.222 -				surface->w,
   5.223 -				surface->h,
   5.224 -				SDL_FALSE,
   5.225 -				surface->pitch,
   5.226 -				VDI_pitch
   5.227 -			);
   5.228 +			for (i=0;i<numrects;i++) {
   5.229 +				void *source,*destination;
   5.230 +				int x1,x2;
   5.231 +
   5.232 +				x1 = rects[i].x & ~15;
   5.233 +				x2 = rects[i].x+rects[i].w;
   5.234 +				if (x2 & 15) {
   5.235 +					x2 = (x2 | 15) +1;
   5.236 +				}
   5.237 +
   5.238 +				source = surface->pixels;
   5.239 +				source += surface->pitch * rects[i].y;
   5.240 +				source += x1;
   5.241 +
   5.242 +				destination = destscr;
   5.243 +				destination += VDI_pitch * rects[i].y;
   5.244 +				destination += x1;
   5.245 +
   5.246 +				/* Convert chunky to planar screen */
   5.247 +				Atari_C2pConvert(
   5.248 +					source,
   5.249 +					destination,
   5.250 +					x2-x1,
   5.251 +					rects[i].h,
   5.252 +					SDL_FALSE,
   5.253 +					surface->pitch,
   5.254 +					VDI_pitch
   5.255 +				);
   5.256 +
   5.257 +			}
   5.258 +
   5.259 +			return;
   5.260  		}
   5.261 -	} else {
   5.262 -		MFDB mfdb_src;
   5.263 -		short blitcoords[8];
   5.264 -		int i;
   5.265  
   5.266 -		mfdb_src.fd_addr=surface->pixels;
   5.267 -		mfdb_src.fd_w=surface->w;
   5.268 -		mfdb_src.fd_h=surface->h;
   5.269 -		mfdb_src.fd_wdwidth=(surface->w) >> 4;
   5.270 -		mfdb_src.fd_stand=0;
   5.271 -	  	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
   5.272 -		mfdb_src.fd_r1=0;
   5.273 -		mfdb_src.fd_r2=0;
   5.274 -		mfdb_src.fd_r3=0;
   5.275 +		if (!(surface->flags & SDL_DOUBLEBUF)) {
   5.276 +			return;
   5.277 +		}
   5.278 +	}
   5.279  
   5.280 -		for ( i=0; i<numrects; ++i ) {
   5.281 -			blitcoords[0] = rects[i].x;
   5.282 -			blitcoords[1] = rects[i].y;
   5.283 -			blitcoords[2] = blitcoords[0] + rects[i].w - 1;
   5.284 -			blitcoords[3] = blitcoords[1] + rects[i].h - 1;
   5.285 +	mfdb_src.fd_addr=surface->pixels;
   5.286 +	mfdb_src.fd_w=surface->w;
   5.287 +	mfdb_src.fd_h=surface->h;
   5.288 +	mfdb_src.fd_wdwidth=(surface->w) >> 4;
   5.289 +	mfdb_src.fd_stand=0;
   5.290 +	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
   5.291 +	mfdb_src.fd_r1=0;
   5.292 +	mfdb_src.fd_r2=0;
   5.293 +	mfdb_src.fd_r3=0;
   5.294  
   5.295 -			blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1);
   5.296 -			blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1);
   5.297 -			blitcoords[6] = blitcoords[4] + rects[i].w - 1;
   5.298 -			blitcoords[7] = blitcoords[5] + rects[i].h - 1;
   5.299 +	for ( i=0; i<numrects; ++i ) {
   5.300 +		blitcoords[0] = rects[i].x;
   5.301 +		blitcoords[1] = rects[i].y;
   5.302 +		blitcoords[2] = blitcoords[0] + rects[i].w - 1;
   5.303 +		blitcoords[3] = blitcoords[1] + rects[i].h - 1;
   5.304  
   5.305 -			vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
   5.306 -		}
   5.307 +		blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1);
   5.308 +		blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1);
   5.309 +		blitcoords[6] = blitcoords[4] + rects[i].w - 1;
   5.310 +		blitcoords[7] = blitcoords[5] + rects[i].h - 1;
   5.311 +
   5.312 +		vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
   5.313  	}
   5.314  }
   5.315  
   5.316 @@ -810,6 +876,9 @@
   5.317  
   5.318  static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)
   5.319  {
   5.320 +	MFDB mfdb_src;
   5.321 +	short blitcoords[8];
   5.322 +
   5.323  	if (VDI_screen) {
   5.324  		if (VDI_format==VDI_FORMAT_INTER) {
   5.325  			void *destscr;
   5.326 @@ -820,7 +889,7 @@
   5.327  			destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
   5.328  			destx = (VDI_w - surface->w) >> 1;
   5.329  			destx &= ~15;
   5.330 -			destscr += VDI_pixelsize * destx;
   5.331 +			destscr += destx;
   5.332  
   5.333  			/* Convert chunky to planar screen */
   5.334  			Atari_C2pConvert(
   5.335 @@ -832,32 +901,35 @@
   5.336  				surface->pitch,
   5.337  				VDI_pitch
   5.338  			);
   5.339 +
   5.340 +			return(0);
   5.341  		}
   5.342 -	} else {
   5.343 -		MFDB mfdb_src;
   5.344 -		short blitcoords[8];
   5.345  
   5.346 -		mfdb_src.fd_addr=surface->pixels;
   5.347 -		mfdb_src.fd_w=surface->w;
   5.348 -		mfdb_src.fd_h=surface->h;
   5.349 -		mfdb_src.fd_wdwidth=(surface->w) >> 4;
   5.350 -		mfdb_src.fd_stand=0;
   5.351 -	  	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
   5.352 -		mfdb_src.fd_r1=0;
   5.353 -		mfdb_src.fd_r2=0;
   5.354 -		mfdb_src.fd_r3=0;
   5.355 +		if (!(surface->flags & SDL_DOUBLEBUF)) {
   5.356 +			return(0);
   5.357 +		}
   5.358 +	}
   5.359 +	
   5.360 +	mfdb_src.fd_addr=surface->pixels;
   5.361 +	mfdb_src.fd_w=surface->w;
   5.362 +	mfdb_src.fd_h=surface->h;
   5.363 +	mfdb_src.fd_wdwidth=(surface->w) >> 4;
   5.364 +	mfdb_src.fd_stand=0;
   5.365 +	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
   5.366 +	mfdb_src.fd_r1=0;
   5.367 +	mfdb_src.fd_r2=0;
   5.368 +	mfdb_src.fd_r3=0;
   5.369  
   5.370 -		blitcoords[0] = 0;
   5.371 -		blitcoords[1] = 0;
   5.372 -		blitcoords[2] = surface->w - 1;
   5.373 -		blitcoords[3] = surface->h - 1;
   5.374 -		blitcoords[4] = (VDI_w - surface->w) >> 1;
   5.375 -		blitcoords[5] = (VDI_h - surface->h) >> 1;
   5.376 -		blitcoords[6] = blitcoords[4] + surface->w - 1;
   5.377 -		blitcoords[7] = blitcoords[5] + surface->h - 1;
   5.378 +	blitcoords[0] = 0;
   5.379 +	blitcoords[1] = 0;
   5.380 +	blitcoords[2] = surface->w - 1;
   5.381 +	blitcoords[3] = surface->h - 1;
   5.382 +	blitcoords[4] = (VDI_w - surface->w) >> 1;
   5.383 +	blitcoords[5] = (VDI_h - surface->h) >> 1;
   5.384 +	blitcoords[6] = blitcoords[4] + surface->w - 1;
   5.385 +	blitcoords[7] = blitcoords[5] + surface->h - 1;
   5.386  
   5.387 -		vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
   5.388 -	}
   5.389 +	vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
   5.390  
   5.391  	return(0);
   5.392  }
   5.393 @@ -894,7 +966,6 @@
   5.394  		return 1;
   5.395  	}
   5.396  
   5.397 -
   5.398  	for(i = 0; i < ncolors; i++)
   5.399  	{
   5.400  		int		r, g, b;
   5.401 @@ -918,18 +989,9 @@
   5.402  static int GEM_ToggleFullScreen(_THIS, int on)
   5.403  {
   5.404  	if (on) {
   5.405 -		if (!GEM_locked) {
   5.406 -			/* Lock AES */
   5.407 -			while (!wind_update(BEG_UPDATE|BEG_MCTRL));
   5.408 -			GEM_locked=SDL_TRUE;
   5.409 -		}
   5.410 +		GEM_LockScreen(this);
   5.411  	} else {
   5.412 -		if (GEM_locked) {
   5.413 -			/* Unlock AES */
   5.414 -			wind_update(END_UPDATE|END_MCTRL);
   5.415 -			GEM_locked=SDL_FALSE;
   5.416 -		}
   5.417 -		/* Redraw all screen */
   5.418 +		GEM_UnlockScreen(this);
   5.419  	}
   5.420  
   5.421  	return(1);
   5.422 @@ -945,15 +1007,8 @@
   5.423  
   5.424  	GEM_FreeBuffers(this);
   5.425  
   5.426 -	if (GEM_locked) {
   5.427 -		/* Restore screen memory, and send REDRAW to all apps */
   5.428 -		form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h);
   5.429 -		/* Unlock AES */
   5.430 -		wind_update(END_UPDATE|END_MCTRL);
   5.431 -		GEM_locked=SDL_FALSE;
   5.432 -	}
   5.433 +	GEM_UnlockScreen(this);
   5.434  
   5.435 -	/* Close AES application */
   5.436  	appl_exit();
   5.437  
   5.438  	/* Restore palette */
   5.439 @@ -990,7 +1045,7 @@
   5.440  	short todo[4];
   5.441  
   5.442  	/* Tell AES we are going to update */
   5.443 -	while (!wind_update(BEG_UPDATE));
   5.444 +	wind_update(BEG_UPDATE);
   5.445  
   5.446  	v_hide_c(VDI_handle);
   5.447  
     6.1 --- a/src/video/xbios/SDL_xbios.c	Sun Mar 24 21:44:06 2002 +0000
     6.2 +++ b/src/video/xbios/SDL_xbios.c	Tue Mar 26 17:37:31 2002 +0000
     6.3 @@ -639,7 +639,10 @@
     6.4  			int x1,x2;
     6.5  
     6.6  			x1 = rects[i].x & ~15;
     6.7 -			x2 = ((rects[i].x+rects[i].w) | 15) +1;
     6.8 +			x2 = rects[i].x+rects[i].w;
     6.9 +			if (x2 & 15) {
    6.10 +				x2 = (x2 | 15) +1;
    6.11 +			}
    6.12  
    6.13  			source = surface->pixels;
    6.14  			source += surface->pitch * rects[i].y;