Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-gme
Commits
279ec0f2
Commit
279ec0f2
authored
Mar 20, 2022
by
Denis Marion
Browse files
fixes audio playback, removed static font in graphics.h, undo merge errors
parent
f594700b
Pipeline
#95281
failed with stages
in 1 minute and 10 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
src/graphics.c
View file @
279ec0f2
...
...
@@ -9,14 +9,14 @@ const short gme_rainbow7[7] = {gme_red,gme_orange,gme_yellow,gme_green,gme_blue,
bool
is_font_pixel
(
unsigned
char
letter
,
int
x
,
int
y
)
{
if
(
letter
>=
0x00
&&
letter
<
0x7F
)
return
((
font8x8_basic
[
letter
][
y
]
&
(
1
<<
x
))
>
0
);
else
if
(
letter
>=
0x80
&&
letter
<
0xA0
)
return
((
font8x8_control
[
letter
-
0x80
][
y
]
&
(
1
<<
x
))
>
0
);
else
if
(
letter
>=
0xA0
&&
letter
<
0x100
)
return
((
font8x8_ext_latin
[
letter
-
0xA0
][
y
]
&
(
1
<<
x
))
>
0
);
else
return
false
;
if
(
letter
>=
0x00
&&
letter
<
0x7F
)
return
((
font8x8_basic
[
letter
][
y
]
&
(
1
<<
x
))
>
0
);
else
if
(
letter
>=
0x80
&&
letter
<
0xA0
)
return
((
font8x8_control
[
letter
-
0x80
][
y
]
&
(
1
<<
x
))
>
0
);
else
if
(
letter
>=
0xA0
&&
letter
<
0x100
)
return
((
font8x8_ext_latin
[
letter
-
0xA0
][
y
]
&
(
1
<<
x
))
>
0
);
else
return
false
;
}
...
...
@@ -52,48 +52,48 @@ void free_surface(surface *surf)
surface
*
clip_surface
(
surface
*
src_surf
,
int
x_src
,
int
y_src
,
int
x0
,
int
y0
,
int
x1
,
int
y1
)
{
int
wx0
,
wy0
,
wx1
,
wy1
;
//world coord
int
lx
,
ly
,
lw
,
lh
;
//local coord
surface
*
clipped_surf
=
NULL
;
//check if completely out of bounds
if
(
(
x_src
+
src_surf
->
width
)
<
x0
int
wx0
,
wy0
,
wx1
,
wy1
;
//world coord
int
lx
,
ly
,
lw
,
lh
;
//local coord
surface
*
clipped_surf
=
NULL
;
//check if completely out of bounds
if
(
(
x_src
+
src_surf
->
width
)
<
x0
||
(
x_src
>
x1
)
||
(
y_src
+
src_surf
->
height
)
<
y0
||
(
y_src
>
y1
))
return
clipped_surf
;
wx0
=
MAX
(
x_src
,
x0
);
wy0
=
MAX
(
y_src
,
y0
);
wx1
=
MIN
(
x_src
+
src_surf
->
width
,
x1
);
wy1
=
MIN
(
y_src
+
src_surf
->
height
,
y1
);
lx
=
wx0
-
x_src
;
ly
=
wy0
-
y_src
;
lw
=
wx1
-
wx0
;
lh
=
wy1
-
wy0
;
clipped_surf
=
create_surface
(
lw
,
lh
,
2
);
copy_surface
(
src_surf
,
clipped_surf
,
lx
,
ly
,
0
,
0
,
lw
,
lh
);
return
clipped_surf
;
return
clipped_surf
;
wx0
=
MAX
(
x_src
,
x0
);
wy0
=
MAX
(
y_src
,
y0
);
wx1
=
MIN
(
x_src
+
src_surf
->
width
,
x1
);
wy1
=
MIN
(
y_src
+
src_surf
->
height
,
y1
);
lx
=
wx0
-
x_src
;
ly
=
wy0
-
y_src
;
lw
=
wx1
-
wx0
;
lh
=
wy1
-
wy0
;
clipped_surf
=
create_surface
(
lw
,
lh
,
2
);
copy_surface
(
src_surf
,
clipped_surf
,
lx
,
ly
,
0
,
0
,
lw
,
lh
);
return
clipped_surf
;
}
void
copy_surface
(
surface
*
src_surf
,
surface
*
dst_surf
,
int
x_src
,
int
y_src
,
int
x_dst
,
int
y_dst
,
int
w
,
int
h
)
{
int
x
,
y
;
unsigned
short
pixel
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
pixel
=
get_pixel
(
src_surf
,
x_src
+
x
,
y_src
+
y
);
set_pixel
(
dst_surf
,
x_dst
+
x
,
y_dst
+
y
,
pixel
);
}
}
int
x
,
y
;
unsigned
short
pixel
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
pixel
=
get_pixel
(
src_surf
,
x_src
+
x
,
y_src
+
y
);
set_pixel
(
dst_surf
,
x_dst
+
x
,
y_dst
+
y
,
pixel
);
}
}
}
void
draw_line
(
surface
*
surf
,
unsigned
short
color
,
int
start_x
,
int
start_y
,
int
end_x
,
int
end_y
)
{
if
(
start_x
==
end_x
)
//vertical line
{
int
y
;
int
y
;
for
(
y
=
start_y
;
y
<=
end_y
;
y
++
)
set_pixel
(
surf
,
start_x
,
y
,
color
);
}
...
...
@@ -124,34 +124,32 @@ void draw_line(surface *surf, unsigned short color, int start_x, int start_y, in
void
draw_box
(
surface
*
surf
,
unsigned
short
color
,
box
b
)
{
draw_line
(
surf
,
color
,
b
.
x0
,
b
.
y0
,
b
.
x1
,
b
.
y0
);
//top line
draw_line
(
surf
,
color
,
b
.
x0
,
b
.
y1
,
b
.
x1
,
b
.
y1
);
//bottom line
draw_line
(
surf
,
color
,
b
.
x0
,
b
.
y0
,
b
.
x0
,
b
.
y1
);
//left line
draw_line
(
surf
,
color
,
b
.
x1
,
b
.
y0
,
b
.
x1
,
b
.
y1
);
//right line
draw_line
(
surf
,
color
,
b
.
x0
,
b
.
y0
,
b
.
x1
,
b
.
y0
);
//top line
draw_line
(
surf
,
color
,
b
.
x0
,
b
.
y1
,
b
.
x1
,
b
.
y1
);
//bottom line
draw_line
(
surf
,
color
,
b
.
x0
,
b
.
y0
,
b
.
x0
,
b
.
y1
);
//left line
draw_line
(
surf
,
color
,
b
.
x1
,
b
.
y0
,
b
.
x1
,
b
.
y1
);
//right line
}
void
draw_shape
(
surface
*
surf
,
unsigned
short
color
,
int
pos_x
,
int
pos_y
,
int
w
,
int
h
)
{
int
y
,
x
;
for
(
y
=
pos_y
;
y
<
(
pos_y
+
h
);
y
++
)
{
for
(
x
=
pos_x
;
x
<
(
pos_x
+
w
);
x
++
)
set_pixel
(
surf
,
x
,
y
,
color
);
}
for
(
y
=
pos_y
;
y
<
(
pos_y
+
h
);
y
++
)
{
for
(
x
=
pos_x
;
x
<
(
pos_x
+
w
);
x
++
)
set_pixel
(
surf
,
x
,
y
,
color
);
}
}
void
draw_letter
(
surface
*
surf
,
unsigned
short
color
,
char
letter
,
int
pos_x
,
int
pos_y
)
{
int
y
,
x
;
//calculate letter offset
int
charx
=
(
letter
%
16
)
*
8
;
int
chary
=
(
letter
>>
4
)
*
8
;
for
(
y
=
0
;
y
<
8
;
y
++
)
{
for
(
x
=
0
;
x
<
8
;
x
++
)
{
if
(
is_font_pixel
(
letter
,
charx
+
x
,
chary
+
y
))
if
(
is_font_pixel
(
(
unsigned
char
)
letter
,
x
,
y
))
set_pixel
(
surf
,
pos_x
+
x
,
pos_y
+
y
,
color
);
}
}
...
...
@@ -159,7 +157,7 @@ void draw_letter(surface *surf, unsigned short color, char letter, int pos_x, in
void
draw_string
(
surface
*
surf
,
unsigned
short
color
,
char
*
text
,
int
pos_x
,
int
pos_y
,
unsigned
int
framecounter
)
{
int
x
;
int
x
;
int
x_offset
=
0
;
int
delta
=
0
;
int
delay
=
30
;
...
...
@@ -167,35 +165,35 @@ void draw_string(surface *surf, unsigned short color, char* text, int pos_x, int
int
frame_delay
=
2
;
int
msglen
=
strlen
(
text
);
surface
*
clipped_surface
=
NULL
;
surface
*
temp_surface
=
create_surface
((
msglen
*
8
),
8
,
2
);
for
(
x
=
0
;
x
<
msglen
;
x
++
)
draw_letter
(
temp_surface
,
color
,
text
[
x
],(
x
*
8
),
0
);
if
((
msglen
*
8
)
>
280
)
surface
*
temp_surface
=
create_surface
((
msglen
*
8
),
8
,
2
);
if
(
temp_surface
)
{
delta
=
(
msglen
*
8
)
-
280
;
modulo
=
delta
+
(
delay
*
2
);
x_offset
=
(
modulo
-
abs
(
framecounter
/
frame_delay
%
(
2
*
modulo
)
-
modulo
))
-
delay
;
// triangle function
x_offset
=
MAX
(
x_offset
,
0
);
//clamp left to add delay
x_offset
=
MIN
(
x_offset
,
delta
);
//clamp right to add delay
}
for
(
x
=
0
;
x
<
msglen
;
x
++
)
draw_letter
(
temp_surface
,
color
,
text
[
x
],(
x
*
8
),
0
);
;
clipped_surface
=
clip_surface
(
temp_surface
,
pos_x
-
x_offset
,
pos_y
,
21
,
21
,
299
,
219
);
if
((
msglen
*
8
)
>
(
surf
->
width
-
40
))
{
delta
=
(
msglen
*
8
)
-
(
surf
->
width
-
40
);
modulo
=
delta
+
(
delay
*
2
);
x_offset
=
(
modulo
-
abs
(
framecounter
/
frame_delay
%
(
2
*
modulo
)
-
modulo
))
-
delay
;
// triangle function
x_offset
=
MAX
(
x_offset
,
0
);
//clamp left to add delay
x_offset
=
MIN
(
x_offset
,
delta
);
//clamp right to add delay
}
if
(
clipped_surface
)
{
copy_surface
(
clipped_surface
,
surf
,
0
,
0
,
pos_x
,
pos_y
,
clipped_surface
->
width
,
clipped_surface
->
height
);
free_surface
(
clipped_surface
);
clipped_surface
=
clip_surface
(
temp_surface
,
pos_x
-
x_offset
,
pos_y
,
21
,
21
,(
surf
->
width
-
21
),(
surf
->
height
-
21
));
if
(
clipped_surface
)
{
copy_surface
(
clipped_surface
,
surf
,
0
,
0
,
pos_x
,
pos_y
,
clipped_surface
->
width
,
clipped_surface
->
height
);
free_surface
(
clipped_surface
);
}
free_surface
(
temp_surface
);
}
free_surface
(
temp_surface
);
}
int
get_string_length
(
char
*
text
)
{
return
strlen
(
text
)
*
8
;
return
strlen
(
text
)
*
8
;
}
src/graphics.h
View file @
279ec0f2
This diff is collapsed.
Click to expand it.
src/libretro.c
View file @
279ec0f2
...
...
@@ -256,7 +256,7 @@ void retro_run(void)
draw_ui
();
video_cb
(
framebuffer
->
pixel_data
,
framebuffer
->
width
,
framebuffer
->
height
,
framebuffer
->
bytes_per_pixel
*
framebuffer
->
width
);
//audio handling
audio_batch_cb
(
play
(),
1470
);
audio_batch_cb
(
play
(),
735
);
if
(
environ_cb
(
RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE
,
&
updated
)
&&
updated
)
{
float
aspect
=
last_aspect
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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