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
tyrquake
Commits
fa1def64
Commit
fa1def64
authored
Oct 27, 2020
by
jdgleaver
Browse files
Fix audio at low frame rates + add OpenDingux target
parent
6b03ccd7
Changes
5
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
fa1def64
*.o
*.o
*.so
Makefile
View file @
fa1def64
...
@@ -222,6 +222,16 @@ else ifeq ($(platform), ctr)
...
@@ -222,6 +222,16 @@ else ifeq ($(platform), ctr)
CFLAGS
+=
-I
$(DEVKITPRO)
/libctru/include
CFLAGS
+=
-I
$(DEVKITPRO)
/libctru/include
STATIC_LINKING
=
1
STATIC_LINKING
=
1
# GCW0
else
ifeq
($(platform), gcw0)
TARGET
:=
$(TARGET_NAME)
_libretro.so
CC
=
/opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
AR
=
/opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
fpic
:=
-fPIC
SHARED
:=
-shared
-Wl
,--version-script
=
common/libretro-link.T
CFLAGS
+=
-DDINGUX
-fomit-frame-pointer
-ffast-math
-march
=
mips32
-mtune
=
mips32r2
-mhard-float
HAVE_NETWORKING
=
0
# Raspberry Pi 1
# Raspberry Pi 1
else
ifeq
($(platform), rpi1)
else
ifeq
($(platform), rpi1)
TARGET
:=
$(TARGET_NAME)
_libretro.so
TARGET
:=
$(TARGET_NAME)
_libretro.so
...
...
common/libretro.c
View file @
fa1def64
...
@@ -97,12 +97,11 @@ static bool libretro_supports_bitmasks = false;
...
@@ -97,12 +97,11 @@ static bool libretro_supports_bitmasks = false;
#define DEFAULT_MEMSIZE_MB 32
#define DEFAULT_MEMSIZE_MB 32
#endif
#endif
#define SAMPLERATE 48000
#define DEFAULT_SAMPLERATE 48000
static
uint16_t
samplerate
=
DEFAULT_SAMPLERATE
;
#define MAX_AUDIO_BUFFER_SIZE (10240)
#define AUDIO_BUFFER_SIZE 4096
static
int16_t
audio_buffer
[
AUDIO_BUFFER_SIZE
];
static
int16_t
audio_buffer
[
MAX_AUDIO_BUFFER_SIZE
];
static
int
audio_buffer_size
;
static
unsigned
audio_buffer_ptr
;
static
unsigned
audio_buffer_ptr
;
// System analog stick range is -0x8000 to 0x8000
// System analog stick range is -0x8000 to 0x8000
...
@@ -149,8 +148,8 @@ gp_layout_t modern = {
...
@@ -149,8 +148,8 @@ gp_layout_t modern = {
{
0
},
{
0
},
},
},
};
};
gp_layout_t
classic
=
{
gp_layout_t
classic
=
{
{
{
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_LEFT
,
"D-Pad Left"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_LEFT
,
"D-Pad Left"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_UP
,
"D-Pad Up"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_UP
,
"D-Pad Up"
},
...
@@ -182,6 +181,7 @@ gp_layout_t classic = {
...
@@ -182,6 +181,7 @@ gp_layout_t classic = {
{
0
},
{
0
},
},
},
};
};
gp_layout_t
classic_alt
=
{
gp_layout_t
classic_alt
=
{
{
{
...
@@ -506,7 +506,7 @@ void retro_get_system_info(struct retro_system_info *info)
...
@@ -506,7 +506,7 @@ void retro_get_system_info(struct retro_system_info *info)
void
retro_get_system_av_info
(
struct
retro_system_av_info
*
info
)
void
retro_get_system_av_info
(
struct
retro_system_av_info
*
info
)
{
{
info
->
timing
.
fps
=
framerate
;
info
->
timing
.
fps
=
framerate
;
info
->
timing
.
sample_rate
=
SAMPLERATE
;
info
->
timing
.
sample_rate
=
samplerate
;
info
->
geometry
.
base_width
=
width
;
info
->
geometry
.
base_width
=
width
;
info
->
geometry
.
base_height
=
height
;
info
->
geometry
.
base_height
=
height
;
...
@@ -727,26 +727,40 @@ static void update_variables(bool startup)
...
@@ -727,26 +727,40 @@ static void update_variables(bool startup)
if
(
startup
)
if
(
startup
)
{
{
if
(
environ_cb
(
RETRO_ENVIRONMENT_GET_VARIABLE
,
&
var
))
{
if
(
environ_cb
(
RETRO_ENVIRONMENT_GET_VARIABLE
,
&
var
))
if
(
!
strcmp
(
var
.
value
,
"auto"
))
{
{
if
(
!
strcmp
(
var
.
value
,
"auto"
))
float
target_framerate
=
0
.
0
f
;
{
if
(
!
environ_cb
(
RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE
,
float
target_framerate
=
0
.
0
f
;
&
target_framerate
))
target_framerate
=
60
.
0
f
;
if
(
!
environ_cb
(
RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE
,
framerate
=
target_framerate
;
&
target_framerate
))
}
target_framerate
=
60
.
0
f
;
else
framerate
=
atof
(
var
.
value
);
framerate
=
target_framerate
;
}
}
else
else
framerate
=
60
.
0
f
;
framerate
=
atof
(
var
.
value
);
if
(
framerate
>
49
.
0
)
}
audio_buffer_size
=
2048
;
else
else
framerate
=
60
.
0
f
;
audio_buffer_size
=
2
*
SAMPLERATE
/
framerate
;
if
(
audio_buffer_size
>
MAX_AUDIO_BUFFER_SIZE
)
/* Note: The audio handling code of the game engine
audio_buffer_size
=
MAX_AUDIO_BUFFER_SIZE
;
* completely falls apart below 50 FPS. To go any
* lower than this, we have to manipulate the actual
* audio sample rate to achieve a fixed 'samples per
* frame' matching the default frame rate of 60. This
* means we get progressively lower quality audio as
* the frame rate decreases, but the alternative is
* no sound at all... */
if
(
framerate
>
49
.
0
f
)
samplerate
=
DEFAULT_SAMPLERATE
;
else
{
samplerate
=
(
uint16_t
)((
float
)
DEFAULT_SAMPLERATE
*
(
framerate
/
60
.
0
f
));
/* Round up to the nearest power of 2 */
samplerate
=
(
samplerate
+
0x1
)
&
~
0x1
;
}
}
}
var
.
key
=
"tyrquake_colored_lighting"
;
var
.
key
=
"tyrquake_colored_lighting"
;
...
@@ -968,10 +982,14 @@ bool retro_load_game(const struct retro_game_info *info)
...
@@ -968,10 +982,14 @@ bool retro_load_game(const struct retro_game_info *info)
strstr
(
path_lower
,
"hipnotic"
)
||
strstr
(
path_lower
,
"hipnotic"
)
||
strstr
(
path_lower
,
"rogue"
)
)
strstr
(
path_lower
,
"rogue"
)
)
{
{
char
tmp_dir
[
1024
];
tmp_dir
[
0
]
=
'\0'
;
#if (defined(HW_RVL) && !defined(WIIU)) || defined(_XBOX1)
#if (defined(HW_RVL) && !defined(WIIU)) || defined(_XBOX1)
MEMSIZE_MB
=
16
;
MEMSIZE_MB
=
16
;
#endif
#endif
extract_directory
(
g_rom_dir
,
g_rom_dir
,
sizeof
(
g_rom_dir
));
extract_directory
(
tmp_dir
,
g_rom_dir
,
sizeof
(
tmp_dir
));
strncpy
(
g_rom_dir
,
tmp_dir
,
sizeof
(
g_rom_dir
)
-
1
);
}
}
memset
(
&
parms
,
0
,
sizeof
(
parms
));
memset
(
&
parms
,
0
,
sizeof
(
parms
));
...
@@ -1301,30 +1319,33 @@ static void audio_process(void)
...
@@ -1301,30 +1319,33 @@ static void audio_process(void)
}
}
static
void
static
void
audio_batch_cb_blocking
(
int16_t
*
sa
,
size_t
sz
)
{
audio_batch_cb_blocking
(
int16_t
*
sa
,
size_t
sz
)
while
(
sz
)
{
{
size_t
r
=
audio_batch_cb
(
sa
,
sz
);
while
(
sz
)
sz
-=
r
;
{
sa
+=
r
;
size_t
r
=
audio_batch_cb
(
sa
,
sz
);
}
sz
-=
r
;
sa
+=
r
;
}
}
}
static
void
audio_callback
(
void
)
static
void
audio_callback
(
void
)
{
{
unsigned
read_first
,
read_second
;
unsigned
read_first
,
read_second
;
const
int
nchans
=
2
;
const
int
nchans
=
2
;
int
samples_per_frame
=
(
nchans
*
SAMPLERATE
)
/
framerate
;
int
samples_per_frame
=
(
nchans
*
samplerate
)
/
framerate
;
unsigned
read_end
=
audio_buffer_ptr
+
samples_per_frame
;
unsigned
read_end
=
audio_buffer_ptr
+
samples_per_frame
;
if
(
read_end
>
audio_buffer_size
)
if
(
read_end
>
AUDIO_BUFFER_SIZE
)
read_end
=
audio_buffer_size
;
read_end
=
AUDIO_BUFFER_SIZE
;
read_first
=
read_end
-
audio_buffer_ptr
;
read_first
=
read_end
-
audio_buffer_ptr
;
read_second
=
samples_per_frame
-
read_first
;
read_second
=
samples_per_frame
-
read_first
;
audio_batch_cb_blocking
(
audio_buffer
+
audio_buffer_ptr
,
read_first
/
nchans
);
audio_batch_cb_blocking
(
audio_buffer
+
audio_buffer_ptr
,
read_first
/
nchans
);
audio_buffer_ptr
+=
read_first
;
audio_buffer_ptr
+=
read_first
;
if
(
read_second
>=
1
)
{
if
(
read_second
>=
1
)
{
audio_batch_cb_blocking
(
audio_buffer
,
read_second
/
nchans
);
audio_batch_cb_blocking
(
audio_buffer
,
read_second
/
nchans
);
audio_buffer_ptr
=
read_second
;
audio_buffer_ptr
=
read_second
;
}
}
...
@@ -1333,12 +1354,12 @@ static void audio_callback(void)
...
@@ -1333,12 +1354,12 @@ static void audio_callback(void)
qboolean
SNDDMA_Init
(
dma_t
*
dma
)
qboolean
SNDDMA_Init
(
dma_t
*
dma
)
{
{
shm
=
dma
;
shm
=
dma
;
shm
->
speed
=
SAMPLERATE
;
shm
->
speed
=
samplerate
;
shm
->
channels
=
2
;
shm
->
channels
=
2
;
shm
->
samplepos
=
0
;
shm
->
samplepos
=
0
;
shm
->
samplebits
=
16
;
shm
->
samplebits
=
16
;
shm
->
signed8
=
0
;
shm
->
signed8
=
0
;
shm
->
samples
=
audio_buffer_size
;
shm
->
samples
=
AUDIO_BUFFER_SIZE
;
shm
->
buffer
=
(
unsigned
char
*
volatile
)
audio_buffer
;
shm
->
buffer
=
(
unsigned
char
*
volatile
)
audio_buffer
;
return
true
;
return
true
;
...
...
common/libretro_core_options.h
View file @
fa1def64
...
@@ -40,7 +40,7 @@ struct retro_core_option_definition option_defs_us[] = {
...
@@ -40,7 +40,7 @@ struct retro_core_option_definition option_defs_us[] = {
{
"360x400"
,
NULL
},
{
"360x400"
,
NULL
},
{
"360x480"
,
NULL
},
{
"360x480"
,
NULL
},
{
"400x224"
,
NULL
},
{
"400x224"
,
NULL
},
{
"400x240"
,
NULL
},
{
"400x240"
,
NULL
},
{
"480x272"
,
NULL
},
{
"480x272"
,
NULL
},
{
"512x224"
,
NULL
},
{
"512x224"
,
NULL
},
{
"512x240"
,
NULL
},
{
"512x240"
,
NULL
},
...
@@ -56,18 +56,20 @@ struct retro_core_option_definition option_defs_us[] = {
...
@@ -56,18 +56,20 @@ struct retro_core_option_definition option_defs_us[] = {
{
"800x600"
,
NULL
},
{
"800x600"
,
NULL
},
{
"960x720"
,
NULL
},
{
"960x720"
,
NULL
},
{
"960x600"
,
NULL
},
{
"960x600"
,
NULL
},
{
"1024x768"
,
NULL
},
{
"1024x768"
,
NULL
},
{
"1280x720"
,
NULL
},
{
"1280x720"
,
NULL
},
{
"1280x800"
,
NULL
},
{
"1280x800"
,
NULL
},
{
"1600x900"
,
NULL
},
{
"1600x900"
,
NULL
},
{
"1600x1000"
,
NULL
},
{
"1600x1000"
,
NULL
},
{
"1600x1200"
,
NULL
},
{
"1600x1200"
,
NULL
},
{
"1920x1080"
,
NULL
},
{
"1920x1080"
,
NULL
},
{
"1920x1200"
,
NULL
},
{
"1920x1200"
,
NULL
},
{
NULL
,
NULL
},
{
NULL
,
NULL
},
},
},
#ifdef _3DS
#if defined(_3DS)
"400x240"
,
"400x240"
#elif defined(DINGUX)
"320x240"
#else
#else
"320x200"
"320x200"
#endif
#endif
...
@@ -78,12 +80,12 @@ struct retro_core_option_definition option_defs_us[] = {
...
@@ -78,12 +80,12 @@ struct retro_core_option_definition option_defs_us[] = {
"Modify framerate. Requires a restart."
,
"Modify framerate. Requires a restart."
,
{
{
{
"auto"
,
"Auto"
},
{
"auto"
,
"Auto"
},
{
"10"
,
"10fps"
},
{
"10"
,
"10fps"
},
{
"15"
,
"15fps"
},
{
"15"
,
"15fps"
},
{
"20"
,
"20fps"
},
{
"20"
,
"20fps"
},
{
"25"
,
"25fps"
},
{
"25"
,
"25fps"
},
{
"30"
,
"30fps"
},
{
"30"
,
"30fps"
},
{
"40"
,
"40fps"
},
{
"40"
,
"40fps"
},
{
"50"
,
"50fps"
},
{
"50"
,
"50fps"
},
{
"60"
,
"60fps"
},
{
"60"
,
"60fps"
},
{
"72"
,
"72fps"
},
{
"72"
,
"72fps"
},
...
@@ -104,8 +106,10 @@ struct retro_core_option_definition option_defs_us[] = {
...
@@ -104,8 +106,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"360"
,
"360fps"
},
{
"360"
,
"360fps"
},
{
NULL
,
NULL
},
{
NULL
,
NULL
},
},
},
#ifdef
_3DS
#if
def
ined(
_3DS
)
"25"
"25"
#elif defined(DINGUX)
"30"
#else
#else
"auto"
"auto"
#endif
#endif
...
...
common/snd_mix.c
View file @
fa1def64
...
@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
...
@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
((x) < (_minval) ? (_minval) : \
((x) < (_minval) ? (_minval) : \
(x) > (_maxval) ? (_maxval) : (x))
(x) > (_maxval) ? (_maxval) : (x))
#define PAINTBUFFER_SIZE
2048
#define PAINTBUFFER_SIZE
4096
portable_samplepair_t
paintbuffer
[
PAINTBUFFER_SIZE
];
portable_samplepair_t
paintbuffer
[
PAINTBUFFER_SIZE
];
int
snd_scaletable
[
32
][
256
];
int
snd_scaletable
[
32
][
256
];
int
*
snd_p
,
snd_linear_count
;
int
*
snd_p
,
snd_linear_count
;
...
...
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