Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dreamcast
vcdc
Commits
8e42797d
Commit
8e42797d
authored
May 26, 2024
by
Donald Haase
Browse files
Update background loading code to behave better when no jpg exists
parent
5695727e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bkg.c
View file @
8e42797d
...
...
@@ -13,7 +13,7 @@ static pvr_ptr_t bkgtexture = NULL;
static
float
horizon
=
340
.
0
f
;
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 */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment