Fix ISO C90 violations in psp render code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c
index 40cbd4d..05d52e7 100644
--- a/src/render/psp/SDL_render_psp.c
+++ b/src/render/psp/SDL_render_psp.c
@@ -165,11 +165,10 @@ void Swap(float *a, float *b)
static int
TextureNextPow2(unsigned int w)
{
+ unsigned int n = 2;
if(w == 0)
return 0;
- unsigned int n = 2;
-
while(w > n)
n <<= 1;
@@ -209,31 +208,32 @@ StartDrawing(SDL_Renderer * renderer)
int
TextureSwizzle(PSP_TextureData *psp_texture)
{
+ int bytewidth, height;
+ int rowblocks, rowblocksadd;
+ unsigned int blockaddress = 0;
+ unsigned int *src = NULL;
+ unsigned char *data = NULL;
+
if(psp_texture->swizzled)
return 1;
- int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
- int height = psp_texture->size / bytewidth;
+ bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
+ height = psp_texture->size / bytewidth;
- int rowblocks = (bytewidth>>4);
- int rowblocksadd = (rowblocks-1)<<7;
- unsigned int blockaddress = 0;
- unsigned int *src = (unsigned int*) psp_texture->data;
+ rowblocks = (bytewidth>>4);
+ rowblocksadd = (rowblocks-1)<<7;
- unsigned char *data = NULL;
- data = SDL_malloc(psp_texture->size);
+ src = (unsigned int*) psp_texture->data;
- int j;
+ data = SDL_malloc(psp_texture->size);
- for(j = 0; j < height; j++, blockaddress += 16)
+ for(int j = 0; j < height; j++, blockaddress += 16)
{
unsigned int *block;
block = (unsigned int*)&data[blockaddress];
- int i;
-
- for(i = 0; i < rowblocks; i++)
+ for(int i = 0; i < rowblocks; i++)
{
*block++ = *src++;
*block++ = *src++;
@@ -254,23 +254,26 @@ TextureSwizzle(PSP_TextureData *psp_texture)
}
int TextureUnswizzle(PSP_TextureData *psp_texture)
{
+ int bytewidth, height;
+ int widthblocks, heightblocks;
+ int dstpitch, dstrow;
+ unsigned int *src = NULL;
+ unsigned char *data = NULL;
+ unsigned char *ydst = NULL;
+
if(!psp_texture->swizzled)
return 1;
- int blockx, blocky;
-
- int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
- int height = psp_texture->size / bytewidth;
+ bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
+ height = psp_texture->size / bytewidth;
- int widthblocks = bytewidth/16;
- int heightblocks = height/8;
+ widthblocks = bytewidth/16;
+ heightblocks = height/8;
- int dstpitch = (bytewidth - 16)/4;
- int dstrow = bytewidth * 8;
+ dstpitch = (bytewidth - 16)/4;
+ dstrow = bytewidth * 8;
- unsigned int *src = (unsigned int*) psp_texture->data;
-
- unsigned char *data = NULL;
+ src = (unsigned int*) psp_texture->data;
data = SDL_malloc(psp_texture->size);
@@ -279,21 +282,19 @@ int TextureUnswizzle(PSP_TextureData *psp_texture)
sceKernelDcacheWritebackAll();
- int j;
+ ydst = (unsigned char *)data;
- unsigned char *ydst = (unsigned char *)data;
-
- for(blocky = 0; blocky < heightblocks; ++blocky)
+ for(int blocky = 0; blocky < heightblocks; ++blocky)
{
unsigned char *xdst = ydst;
- for(blockx = 0; blockx < widthblocks; ++blockx)
+ for(int blockx = 0; blockx < widthblocks; ++blockx)
{
unsigned int *block;
block = (unsigned int*)xdst;
- for(j = 0; j < 8; ++j)
+ for(int j = 0; j < 8; ++j)
{
*(block++) = *(src++);
*(block++) = *(src++);
@@ -707,6 +708,10 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
float u1 = srcrect->x + srcrect->w;
float v1 = srcrect->y + srcrect->h;
+ const float cw = c * width;
+ const float sw = s * width;
+ const float ch = c * height;
+ const float sh = s * height;
if (!verts) {
return -1;
@@ -716,11 +721,6 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
MathSincos(degToRad(angle), &s, &c);
- const float cw = c * width;
- const float sw = s * width;
- const float ch = c * height;
- const float sh = s * height;
-
if (flip & SDL_FLIP_VERTICAL) {
Swap(&v0, &v1);
}
@@ -799,7 +799,7 @@ static int
PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
{
PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata;
-
+ Uint8 *gpumem = NULL;
StartDrawing(renderer);
/* note that before the renderer interface change, this would do extrememly small
@@ -808,7 +808,7 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
I don't know what the limits on PSP hardware are. It might be useful to have
rendering backends report a reasonable maximum, so the higher level can flush
if we appear to be exceeding that. */
- Uint8 *gpumem = (Uint8 *) sceGuGetMemory(vertsize);
+ gpumem = (Uint8 *) sceGuGetMemory(vertsize);
if (!gpumem) {
return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int) vertsize);
}