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
retro8
Commits
63fd938d
Commit
63fd938d
authored
Dec 19, 2019
by
Jack
Browse files
fixes for GCC
parent
1a4ec101
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/common.h
View file @
63fd938d
...
...
@@ -51,8 +51,11 @@ private:
#define SOUND_ENABLED true
#ifdef _WIN32
#define LOGD(x , ...) printf(x"\n", __VA_ARGS__)
#else
#define LOGD(...)
#endif
#ifdef _WIN32
#define MOUSE_ENABLED true
...
...
@@ -61,4 +64,4 @@ private:
#define TEST_MODE false
#else
#define MOUSE_ENABLED false
#endif
\ No newline at end of file
#endif
src/lua/lparser.c
View file @
63fd938d
...
...
@@ -1414,7 +1414,7 @@ static void forstat (LexState *ls, int line) {
}
void
retstat
(
LexState
*
ls
);
static
void
retstat
(
LexState
*
ls
);
static
void
inline_if
(
LexState
*
ls
,
expdesc
*
v
)
{
...
...
@@ -1431,7 +1431,7 @@ static void inline_if(LexState* ls, expdesc* v)
enterblock
(
fs
,
&
bl
,
0
);
jf
=
v
->
f
;
/* handling return manually because otherwise any valid LHS
/* handling return manually because otherwise any valid LHS
would be parsed as return value for return statement */
if
(
ls
->
t
.
token
==
TK_RETURN
)
retstat
(
ls
);
...
...
src/vm/lua_bridge.cpp
View file @
63fd938d
...
...
@@ -142,7 +142,7 @@ int spr(lua_State* L)
if
(
lua_gettop
(
L
)
>
3
)
{
assert
(
lua_gettop
(
L
)
>=
5
);
real_t
w
=
lua_tonumber
(
L
,
4
);
real_t
h
=
lua_tonumber
(
L
,
5
);
bool
fx
=
false
,
fy
=
false
;
...
...
@@ -152,7 +152,7 @@ int spr(lua_State* L)
if
(
lua_gettop
(
L
)
>=
7
)
fy
=
lua_toboolean
(
L
,
7
);
machine
.
spr
(
idx
,
x
,
y
,
w
,
h
,
fx
,
fy
);
}
else
...
...
@@ -342,8 +342,9 @@ namespace debug
int
breakpoint
(
lua_State
*
L
)
{
#if _WIN32
__debugbreak
();
#endif
return
0
;
}
}
...
...
@@ -683,7 +684,7 @@ namespace platform
return
1
;
}
int
btn
(
lua_State
*
L
)
{
/* we're asking for a specific button*/
...
...
@@ -762,7 +763,7 @@ namespace platform
int
dget
(
lua_State
*
L
)
{
index_t
idx
=
lua_tonumber
(
L
,
1
);
lua_pushnumber
(
L
,
*
machine
.
memory
().
cartData
(
idx
));
return
1
;
...
...
@@ -770,7 +771,7 @@ namespace platform
int
flip
(
lua_State
*
L
)
{
//TODO: this call should syncronize to 30fps, at the moment it just
//TODO: this call should syncronize to 30fps, at the moment it just
// returns producing a lot of flips in non synchronized code (eg. _init() busy loop)
machine
.
flip
();
...
...
@@ -874,7 +875,7 @@ void Code::loadAPI()
{
L
=
luaL_newstate
();
}
std
::
ifstream
apiFile
(
"api.lua"
);
std
::
string
api
((
std
::
istreambuf_iterator
<
char
>
(
apiFile
)),
std
::
istreambuf_iterator
<
char
>
());
...
...
@@ -887,10 +888,10 @@ void Code::printError(const char* where)
//for (int i = 1; i < lua_gettop(L); ++i)
{
std
::
cout
<<
"Error on "
<<
where
<<
std
::
endl
;
//luaL_traceback(L, L, NULL, 1);
//printf("%s\n", lua_tostring(L, -1));
if
(
lua_isstring
(
L
,
-
1
))
{
const
char
*
message
=
lua_tostring
(
L
,
-
1
);
...
...
src/vm/sound.cpp
View file @
63fd938d
...
...
@@ -156,9 +156,13 @@ DSP dsp(44100);
// C C# D D# E F F# G G# A A# B
constexpr
std
::
array
<
float
,
12
>
Note
::
frequencies
;
constexpr
float
PULSE_WAVE_DEFAULT_DUTY
=
1
/
3.0
f
;
constexpr
float
ORGAN_DEFAULT_COEFFICIENT
=
0.5
f
;
size_t
position
=
0
;
int16_t
*
rendered
=
nullptr
;
void
audio_callback
(
void
*
data
,
uint8_t
*
cbuffer
,
int
length
)
{
...
...
@@ -172,7 +176,7 @@ void APU::init()
{
static_assert
(
sizeof
(
SoundSample
)
==
2
,
"Must be 2 bytes"
);
static_assert
(
sizeof
(
Sound
)
==
68
,
"Must be 68 bytes"
);
SDL_AudioSpec
wantSpec
;
wantSpec
.
freq
=
44100
;
wantSpec
.
format
=
AUDIO_S16SYS
;
...
...
@@ -182,7 +186,7 @@ void APU::init()
wantSpec
.
callback
=
audio_callback
;
for
(
auto
&
channel
:
channels
)
channel
.
sound
=
nullptr
;
device
=
SDL_OpenAudioDevice
(
NULL
,
0
,
&
wantSpec
,
&
spec
,
0
);
if
(
!
device
)
...
...
@@ -225,11 +229,11 @@ void APU::handleCommands()
if
(
queueMutex
.
try_lock
())
{
for
(
Command
&
c
:
queue
)
{
{
if
(
!
c
.
isMusic
)
{
auto
&
s
=
c
.
sound
;
/* stop sound on channel*/
if
(
s
.
index
==
-
1
)
{
...
...
@@ -319,11 +323,11 @@ void APU::updateMusic()
/* will use channel if channel is forced or there's no sound currently playing there */
bool
willUseChannel
=
((
mstate
.
channelMask
&
(
1
<<
i
))
!=
0
)
||
!
channels
[
i
].
sound
;
}
}
}
void
APU
::
updateChannel
(
SoundState
&
channel
,
const
Music
*
music
)
...
...
@@ -345,9 +349,9 @@ void APU::updateChannel(SoundState& channel, const Music* music)
channel
.
sound
=
nullptr
;
return
;
}
++
mstate
.
pattern
;
if
(
music
->
isLoopEnd
()
||
mstate
.
pattern
==
MUSIC_COUNT
)
{
music_index_t
i
=
mstate
.
pattern
-
1
;
...
...
@@ -391,7 +395,7 @@ void APU::renderSound(const SoundState& channel, int16_t* buffer, size_t samples
constexpr
int16_t
maxVolume
=
4096
;
const
int16_t
volume
=
(
maxVolume
/
8
)
*
sample
.
volume
();
const
frequency_t
frequency
=
Note
::
frequency
(
sample
.
pitch
());
/* render samples */
switch
(
sample
.
waveform
())
{
...
...
@@ -421,15 +425,13 @@ void APU::renderSound(const SoundState& channel, int16_t* buffer, size_t samples
void
APU
::
renderSounds
(
int16_t
*
dest
,
size_t
totalSamples
)
{
memset
(
dest
,
0
,
sizeof
(
int16_t
)
*
totalSamples
);
//return;
handleCommands
();
constexpr
size_t
rate
=
44100
;
constexpr
int16_t
maxVolume
=
4096
;
memset
(
dest
,
0
,
sizeof
(
int16_t
)
*
totalSamples
);
for
(
size_t
i
=
0
;
i
<
CHANNEL_COUNT
;
++
i
)
{
int16_t
*
buffer
=
dest
;
...
...
@@ -437,7 +439,7 @@ void APU::renderSounds(int16_t* dest, size_t totalSamples)
SoundState
&
channel
=
channels
[
i
].
sound
?
channels
[
i
]
:
mstate
.
channels
[
i
];
const
Music
*
music
=
&
channel
==
&
this
->
mstate
.
channels
[
i
]
?
this
->
mstate
.
music
:
nullptr
;
//TODO: crappy comparison
if
(
channel
.
sound
)
{
const
size_t
samplePerTick
=
(
44100
/
128
)
*
(
channel
.
sound
->
speed
+
1
);
...
...
@@ -451,12 +453,10 @@ void APU::renderSounds(int16_t* dest, size_t totalSamples)
samples
-=
available
;
buffer
+=
available
;
channel
.
position
+=
available
;
auto
oldSampel
=
channel
.
sample
;
channel
.
sample
=
channel
.
position
/
samplePerTick
;
updateChannel
(
channel
,
music
);
}
}
}
}
\ No newline at end of file
}
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