Commit 8e42797d authored by Donald Haase's avatar Donald Haase
Browse files

Update background loading code to behave better when no jpg exists

parent 5695727e
......@@ -13,7 +13,7 @@ static pvr_ptr_t bkgtexture = NULL;
static float horizon = 340.0f;
int draw_mode = 0;
int cleared = 0;
kos_img_t *img;
kos_img_t *img = NULL;
void bkg_clear()
{
......@@ -52,46 +52,48 @@ uint16 *image, *texture;
}
/* Make a nice (now familiar =) XOR pattern texture */
void bkg_setup() {
int x, y;
uint16 *texture;
file_t infile;
int file_there = 1;
uint16 *image;
file_there = 1;
if ((infile = fs_open("/cd/vcdc.jpg", O_RDONLY)) == 0) {
file_there = 0;
}
fs_close (infile);
if (file_there)
{
img = (kos_img_t *)(malloc(sizeof(kos_img_t)));
bkgtexture = pvr_mem_malloc(1024*512*2);
draw_mode = 1;
jpeg_to_img("/cd/vcdc.jpg",1, img);
image = (uint16 *)img->data;
texture = (uint16 *)bkgtexture;
for (y=0; y<480; y++)
{
for (x=0; x<640; x++)
texture[x] = image[x];
texture += 1024; image +=640;
}
}
/* chktexture = pvr_mem_malloc(64*64*2);
texture = (uint16*)chktexture;
for (y=0; y<64; y++)
for (x=0; x<64; x++) {
int v = ((x*4)^(y*4)) & 255;
*texture++ = ((v >> 3) << 11)
| ((v >> 2) << 5)
| ((v >> 3) << 0);
} */
int x, y;
uint16 *texture;
file_t infile;
int file_there = 1;
uint16 *image;
file_there = 1;
if ((infile = fs_open("/cd/vcdc.jpg", O_RDONLY)) == 0) {
file_there = 0;
}
fs_close (infile);
if (file_there) {
if(!img)
img = (kos_img_t *)(calloc(1, sizeof(kos_img_t)));
if(jpeg_to_img("/cd/vcdc.jpg",1, img) != 0)
return;
bkgtexture = pvr_mem_malloc(1024*512*2);
draw_mode = 1;
image = (uint16 *)img->data;
texture = (uint16 *)bkgtexture;
for (y=0; y<480; y++)
{
for (x=0; x<640; x++)
texture[x] = image[x];
texture += 1024; image +=640;
}
}
/* chktexture = pvr_mem_malloc(64*64*2);
texture = (uint16*)chktexture;
for (y=0; y<64; y++)
for (x=0; x<64; x++) {
int v = ((x*4)^(y*4)) & 255;
*texture++ = ((v >> 3) << 11)
| ((v >> 2) << 5)
| ((v >> 3) << 0);
} */
}
/* Draws the floor polygon */
......
Supports Markdown
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