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
75743fe2
Unverified
Commit
75743fe2
authored
Mar 11, 2022
by
Libretro-Admin
Committed by
GitHub
Mar 11, 2022
Browse files
Merge pull request #11 from phcoder/sev1
Several fixes
parents
25efe2fc
2c02a37b
Pipeline
#94129
passed with stages
in 9 minutes and 15 seconds
Changes
6
Pipelines
5
Show whitespace changes
Inline
Side-by-side
src/libretro/libretro.cpp
View file @
75743fe2
...
...
@@ -135,6 +135,24 @@ static bool tryScreen16() {
return
true
;
}
static
struct
retro_input_descriptor
input_desc
[]
=
{
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_LEFT
,
"Left"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_DOWN
,
"Down"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_RIGHT
,
"Right"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_UP
,
"Up"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_A
,
"O"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_B
,
"X"
},
{
1
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_LEFT
,
"Left"
},
{
1
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_DOWN
,
"Down"
},
{
1
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_RIGHT
,
"Right"
},
{
1
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_UP
,
"Up"
},
{
1
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_A
,
"O"
},
{
1
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_B
,
"X"
},
{
0
},
};
extern
"C"
{
unsigned
retro_api_version
()
...
...
@@ -185,6 +203,8 @@ extern "C"
retro_log_callback
logger
;
if
(
e
(
RETRO_ENVIRONMENT_GET_LOG_INTERFACE
,
&
logger
))
env
.
logger
=
logger
.
log
;
e
(
RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS
,
input_desc
);
}
void
retro_set_video_refresh
(
retro_video_refresh_t
callback
)
{
env
.
video
=
callback
;
}
...
...
@@ -338,42 +358,33 @@ extern "C"
/* manage input */
{
struct
BtPair
{
unsigned
player
;
int16_t
rabt
;
size_t
r8bt
;
bool
isSet
;
const
static
int16_t
mapping
[
retro8
::
BUTTON_COUNT
]
=
{
RETRO_DEVICE_ID_JOYPAD_LEFT
,
RETRO_DEVICE_ID_JOYPAD_RIGHT
,
RETRO_DEVICE_ID_JOYPAD_UP
,
RETRO_DEVICE_ID_JOYPAD_DOWN
,
RETRO_DEVICE_ID_JOYPAD_A
,
RETRO_DEVICE_ID_JOYPAD_B
,
};
static
std
::
array
<
BtPair
,
retro8
::
BUTTON_COUNT
+
2
>
mapping
=
{
{
{
0
,
RETRO_DEVICE_ID_JOYPAD_LEFT
,
0
,
false
},
{
0
,
RETRO_DEVICE_ID_JOYPAD_RIGHT
,
1
,
false
},
{
0
,
RETRO_DEVICE_ID_JOYPAD_UP
,
2
,
false
},
{
0
,
RETRO_DEVICE_ID_JOYPAD_DOWN
,
3
,
false
},
{
0
,
RETRO_DEVICE_ID_JOYPAD_A
,
4
,
false
},
{
0
,
RETRO_DEVICE_ID_JOYPAD_B
,
5
,
false
},
{
1
,
RETRO_DEVICE_ID_JOYPAD_X
,
4
,
false
},
{
1
,
RETRO_DEVICE_ID_JOYPAD_Y
,
5
,
false
},
}
};
//TODO: add mapping for action1/2 of player 2 because it's used by some games
static
bool
btnState
[
retro8
::
PLAYER_COUNT
][
retro8
::
BUTTON_COUNT
];
env
.
inputPoll
();
for
(
auto
&
entry
:
mapping
)
for
(
unsigned
player
=
0
;
player
<
retro8
::
PLAYER_COUNT
;
player
++
)
{
const
bool
isSet
=
env
.
inputState
(
entry
.
player
,
RETRO_DEVICE_JOYPAD
,
0
,
entry
.
rabt
);
const
bool
wasSet
=
entry
.
isSet
;
for
(
unsigned
r8bt
=
0
;
r8bt
<
retro8
::
BUTTON_COUNT
;
r8bt
++
)
{
const
bool
isSet
=
env
.
inputState
(
player
,
RETRO_DEVICE_JOYPAD
,
0
,
mapping
[
r8bt
]);
const
bool
wasSet
=
btnState
[
player
][
r8bt
];
if
(
wasSet
!=
isSet
)
input
.
manageKey
(
entry
.
player
,
entry
.
r8bt
,
isSet
);
input
.
manageKey
(
player
,
r8bt
,
isSet
);
entry
.
isSet
=
isSet
;
btnState
[
player
][
r8bt
]
=
isSet
;
}
input
.
tick
();
}
}
}
...
...
src/vm/gfx.h
View file @
75743fe2
...
...
@@ -73,7 +73,7 @@ namespace retro8
};
static
color_t
colorForRGB
(
uint32_t
color
)
static
inline
color_t
colorForRGB
(
uint32_t
color
)
{
switch
(
color
&
0x00ffffff
)
{
...
...
src/vm/lua_bridge.cpp
View file @
75743fe2
...
...
@@ -225,7 +225,6 @@ int palt(lua_State* L)
{
color_t
c
=
color_t
(
int
(
lua_tonumber
(
L
,
1
)));
int
f
=
lua_toboolean
(
L
,
2
);
palette_index_t
index
=
gfx
::
DRAW_PALETTE_INDEX
;
machine
->
memory
().
paletteAt
(
gfx
::
DRAW_PALETTE_INDEX
)
->
transparent
(
c
,
f
);
}
...
...
@@ -845,7 +844,7 @@ namespace platform
int32_t
length
=
lua_tonumber
(
L
,
3
);
if
(
length
>
0
)
std
::
memset
(
machine
->
memory
().
base
()
+
addr
,
0
,
length
);
std
::
memset
(
machine
->
memory
().
base
()
+
addr
,
value
,
length
);
return
0
;
}
...
...
src/vm/machine.cpp
View file @
75743fe2
...
...
@@ -183,7 +183,6 @@ void Machine::circfill(coord_t xc, coord_t yc, amount_t r, color_t color)
float
d
=
3
-
2
*
r
;
circFillHelper
(
xc
,
yc
,
x
,
y
,
color
);
int
ctr
=
0
;
while
(
y
>=
x
)
{
x
++
;
...
...
src/vm/sound.cpp
View file @
75743fe2
...
...
@@ -405,9 +405,6 @@ void APU::renderSounds(int16_t* dest, size_t totalSamples)
{
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
)
...
...
src/vm/sound.h
View file @
75743fe2
...
...
@@ -228,7 +228,7 @@ namespace retro8
public:
APU
(
Memory
&
memory
)
:
memory
(
memory
),
_soundEnabled
(
true
),
_musicEnabled
(
true
)
,
dsp
(
44100
)
{
}
APU
(
Memory
&
memory
)
:
memory
(
memory
),
dsp
(
44100
),
_soundEnabled
(
true
),
_musicEnabled
(
true
)
{
}
void
init
();
...
...
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