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