src/video/riscos/SDL_wimpvideo.c
branchSDL-1.2
changeset 12913 d07b4feae69c
parent 12786 4e73be7b4787
child 13054 d07097a0e57e
equal deleted inserted replaced
12831:f1f5878be5db 12913:d07b4feae69c
    70 	{
    70 	{
    71 		/* Not a good match - look for a supported format which is correct */
    71 		/* Not a good match - look for a supported format which is correct */
    72 		fmt = WIMP_FindSupportedSpriteFormat(bpp);
    72 		fmt = WIMP_FindSupportedSpriteFormat(bpp);
    73 		if (fmt == NULL)
    73 		if (fmt == NULL)
    74 		{
    74 		{
    75 			SDL_SetError("Pixel depth not supported");
    75 			SDL_SetError("Pixel depth %d not supported", bpp);
    76 			return NULL;
    76 			return NULL;
    77 		}
    77 		}
    78 	}
    78 	}
    79 
    79 
    80 	if (fmt->sdl_bpp == 8)
    80 	if (fmt->sdl_bpp == 8)
    86 
    86 
    87 /* 	printf("Setting mode %dx%d\n", width, height);*/
    87 /* 	printf("Setting mode %dx%d\n", width, height);*/
    88 
    88 
    89 	/* Allocate the new pixel format for the screen */
    89 	/* Allocate the new pixel format for the screen */
    90 	if ( ! SDL_ReallocFormat(current, fmt->sdl_bpp, fmt->rmask, fmt->gmask, fmt->bmask, 0) ) {
    90 	if ( ! SDL_ReallocFormat(current, fmt->sdl_bpp, fmt->rmask, fmt->gmask, fmt->bmask, 0) ) {
    91 		SDL_SetError("Couldn't allocate new pixel format for requested mode");
       
    92 		return(NULL);
    91 		return(NULL);
    93 	}
    92 	}
    94 
    93 
    95 	/* Set up the new mode framebuffer */
    94 	/* Set up the new mode framebuffer */
    96 	current->w = width;
    95 	current->w = width;
    98 
    97 
    99 	if (bpp == 15) bpp = 16;
    98 	if (bpp == 15) bpp = 16;
   100 	buffer = WIMP_CreateBuffer(width, height, &fmt->ro);
    99 	buffer = WIMP_CreateBuffer(width, height, &fmt->ro);
   101 	if (buffer == NULL)
   100 	if (buffer == NULL)
   102 	{
   101 	{
   103 		SDL_SetError("Couldn't create sprite for video memory");
       
   104 		return (NULL);
   102 		return (NULL);
   105 	}
   103 	}
   106 
   104 
   107 	this->hidden->bank[0] = buffer + 60; /* Start of sprite data */
   105 	this->hidden->bank[0] = buffer + 60; /* Start of sprite data */
   108 	if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */
   106 	if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */
   131 	current->pixels = this->hidden->bank[0];
   129 	current->pixels = this->hidden->bank[0];
   132 
   130 
   133 
   131 
   134 	if (WIMP_SetupWindow(this, current) == 0)
   132 	if (WIMP_SetupWindow(this, current) == 0)
   135 	{
   133 	{
   136 		SDL_SetError("Unable to create window to display surface");
       
   137 		return NULL;
   134 		return NULL;
   138 	}
   135 	}
   139 
   136 
   140 	/* Reset device functions for the wimp */
   137 	/* Reset device functions for the wimp */
   141 	WIMP_SetDeviceMode(this);
   138 	WIMP_SetDeviceMode(this);
   211 
   208 
   212 /* Setup the Window to display the surface */
   209 /* Setup the Window to display the surface */
   213 unsigned int WIMP_SetupWindow(_THIS, SDL_Surface *surface)
   210 unsigned int WIMP_SetupWindow(_THIS, SDL_Surface *surface)
   214 {
   211 {
   215 	_kernel_swi_regs regs;
   212 	_kernel_swi_regs regs;
       
   213 	_kernel_oserror *error;
   216 	int window_data[23];
   214 	int window_data[23];
   217     int	*window_block = window_data+1;
   215     int	*window_block = window_data+1;
   218 	int x = ((this->hidden->screen_width << this->hidden->xeig) - (surface->w << 1)) / 2;
   216 	int x = ((this->hidden->screen_width << this->hidden->xeig) - (surface->w << 1)) / 2;
   219 	int y = ((this->hidden->screen_height << this->hidden->yeig) - (surface->h << 1)) / 2;    
   217 	int y = ((this->hidden->screen_height << this->hidden->yeig) - (surface->h << 1)) / 2;    
   220 
   218 
   253    window_block[21] = 0;			 /* Number of icons */
   251    window_block[21] = 0;			 /* Number of icons */
   254 
   252 
   255    regs.r[1] = (unsigned int)(window_block);
   253    regs.r[1] = (unsigned int)(window_block);
   256    
   254    
   257    /* Create the window */
   255    /* Create the window */
   258    if (_kernel_swi(Wimp_CreateWindow, &regs, &regs) == NULL)
   256    error = _kernel_swi(Wimp_CreateWindow, &regs, &regs);
       
   257    if (error == NULL)
   259    {
   258    {
   260 	   this->hidden->window_handle = window_data[0] = regs.r[0];
   259 	   this->hidden->window_handle = window_data[0] = regs.r[0];
   261 
   260 
   262 	   /* Show the window on the screen */
   261 	   /* Show the window on the screen */
   263 	   regs.r[1] = (unsigned int)window_data;
   262 	   regs.r[1] = (unsigned int)window_data;
   266           WIMP_SetFocus(this->hidden->window_handle);
   265           WIMP_SetFocus(this->hidden->window_handle);
   267        } else
   266        } else
   268        {
   267        {
   269 		  WIMP_DeleteWindow(this);
   268 		  WIMP_DeleteWindow(this);
   270 	   }
   269 	   }
       
   270    } else {
       
   271        SDL_SetError("Unable to create window: %s (%i)", error->errmess, error->errnum);
   271    }
   272    }
   272    
   273 
   273    return this->hidden->window_handle;
   274    return this->hidden->window_handle;
   274 }
   275 }
   275 
   276 
   276 /* Destroy the Window */
   277 /* Destroy the Window */
   277 
   278