SDL_riscossprite.c revision 9682c8870b8ff5e4ac2e4c70b759f791c6f38c1f
19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Library General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Library General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Library General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 27 March 2003 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Implements Sprite plotting code for wimp display.window 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "kernel.h" 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "swis.h" 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_stdinc.h" 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_riscosvideo.h" 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void WIMP_ReadModeInfo(_THIS); 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid WIMP_PaletteChanged(_THIS); 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Create sprite buffer for screen */ 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallunsigned char *WIMP_CreateBuffer(int width, int height, int bpp) 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int size; 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char sprite_name[12] = "display"; 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unsigned char *buffer; 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi_regs regs; 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int bytesPerPixel; 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int bytesPerRow; 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int offsetToSpriteData = 60; 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(bpp) 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 32: bytesPerPixel = 4; break; 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 16: bytesPerPixel = 2; break; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 8: 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bytesPerPixel = 1; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall offsetToSpriteData += 2048; /* Add in size of palette */ 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bytesPerRow = bytesPerPixel * width; 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((bytesPerRow & 3) != 0) 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bytesPerRow += 4 - (bytesPerRow & 3); 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall size = bytesPerRow * height; 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall buffer = SDL_malloc( (size_t) size + offsetToSpriteData ); 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!buffer) return NULL; 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialise a sprite area */ 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *(unsigned int *)buffer = size + offsetToSpriteData; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *(unsigned int *)(buffer + 8) = 16; 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[0] = 256+9; 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[1] = (unsigned int)buffer; 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi(OS_SpriteOp, ®s, ®s); 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[0] = 256+15; 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[1] = (unsigned int)buffer; 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[2] = (unsigned int)&sprite_name; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[3] = 0; /* Palette flag: 0 = no palette */ 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[4] = width; 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[5] = height; 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp == 8) 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Use old style mode number */ 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[6] = 28; /* 8bpp 90x90dpi */ 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[6] = (((bpp == 16) ? 5 : 6) << 27) /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */ 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall | (90 << 14) /* Vertical dpi */ 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall | (90 << 1) /* Horizontal dpi */ 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall | 1; /* Marker to distinguish between mode selectors and sprite modes */ 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (_kernel_swi(OS_SpriteOp, ®s, ®s) == NULL) 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp == 8) 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Modify sprite to take into account 256 colour palette */ 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int *sprite = (int *)(buffer + 16); 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Adjust sprite offsets */ 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprite[0] += 2048; 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprite[8] += 2048; 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprite[9] += 2048; 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Adjust sprite area next free pointer */ 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (*(int *)(buffer+12)) += 2048; 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Don't need to set up palette as SDL sets up the default 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 256 colour palette */ 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* { 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int *pal = sprite + 11; 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unsigned int j; 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unsigned int entry; 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (j = 0; j < 255; j++) 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall entry = (j << 24) | (j << 16) | (j << 8); 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *pal++ = entry; 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *pal++ = entry; 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(buffer); 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall buffer = NULL; 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return buffer; 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Setup translation buffers for the sprite plotting */ 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid WIMP_SetupPlotInfo(_THIS) 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi_regs regs; 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int *sprite = ((int *)this->hidden->bank[1])+4; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[0] = (unsigned int)this->hidden->bank[1]; 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[1] = (unsigned int)sprite; 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[2] = -1; /* Current mode */ 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[3] = -1; /* Current palette */ 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[4] = 0; /* Get size of buffer */ 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[5] = 1|2|16; /* R1 - pointer to sprite and can use full palette words */ 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[6] = 0; 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[7] = 0; 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (this->hidden->pixtrans) SDL_free(this->hidden->pixtrans); 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->hidden->pixtrans = 0; 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the size required for the buffer */ 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (regs.r[4]) 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->hidden->pixtrans = SDL_malloc(regs.r[4]); 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[4] = (unsigned int)this->hidden->pixtrans; 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Actually read the buffer */ 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Plot the sprite in the given context */ 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid WIMP_PlotSprite(_THIS, int x, int y) 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi_regs regs; 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_oserror *err; 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[0] = 52 + 512; 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[1] = (unsigned int)this->hidden->bank[1]; 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[2] = (unsigned int)this->hidden->bank[1]+16; 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[3] = x; 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[4] = y; 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[5] = 0|32; /* Overwrite screen and pixtrans contains wide colour entries */ 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[6] = 0; /* No scale factors i.e. 1:1 */ 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[7] = (int)this->hidden->pixtrans; 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int *p = (int *)this->hidden->pixtrans; 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("OS_SpriteOp failed \n%s\n",err->errmess); 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("pixtrans %d\n", (int)this->hidden->pixtrans); 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%x %x %x\n", p[0], p[1], p[2]); 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Wimp mode has changes so update colour mapping and pixel sizes 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall of windows and the sprites they plot */ 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid WIMP_ModeChanged(_THIS) 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int oldXeig = this->hidden->xeig; 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int oldYeig = this->hidden->yeig; 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIMP_ReadModeInfo(this); 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Only need to update the palette */ 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIMP_PaletteChanged(this); 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi_regs regs; 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int window_state[9]; 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int extent[4]; 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int currWidth, currHeight; 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int newWidth, newHeight; 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Need to resize windows and update the palette */ 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIMP_SetupPlotInfo(this); 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall window_state[0] = this->hidden->window_handle; 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[1] = (unsigned int)window_state; 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi(Wimp_GetWindowState, ®s, ®s); 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall currWidth = window_state[3] - window_state[1]; 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall currHeight = window_state[4] - window_state[2]; 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall newWidth = (currWidth >> oldXeig) << this->hidden->xeig; 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall newHeight = (currHeight >> oldYeig) << this->hidden->yeig; 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Need to avoid extent getting too small for visible part 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall of window */ 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall extent[0] = 0; 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (currHeight <= newHeight) 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall extent[1] = -newHeight; 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall extent[1] = -currHeight; 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (currWidth <= newWidth) 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall extent[2] = newWidth; 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall extent[2] = currWidth; 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall extent[3] = 0; 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[0] = this->hidden->window_handle; 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall regs.r[1] = (int)extent; 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _kernel_swi(Wimp_SetExtent, ®s, ®s); 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*TODO: May need to set flag to resize window on next open */ 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Palette has changed so update palettes used for windows sprites */ 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid WIMP_PaletteChanged(_THIS) 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WIMP_SetupPlotInfo(this); 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 266