Unverified Commit 75743fe2 authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
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
......@@ -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,41 +358,32 @@ 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);
if (wasSet != isSet)
input.manageKey(player, r8bt, isSet);
entry.isSet = isSet;
}
btnState[player][r8bt] = isSet;
}
input.tick();
input.tick();
}
}
}
......
......@@ -73,7 +73,7 @@ namespace retro8
};
static color_t colorForRGB(uint32_t color)
static inline color_t colorForRGB(uint32_t color)
{
switch (color & 0x00ffffff)
{
......
......@@ -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;
}
......
......@@ -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++;
......
......@@ -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)
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment