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() { ...@@ -135,6 +135,24 @@ static bool tryScreen16() {
return true; 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" extern "C"
{ {
unsigned retro_api_version() unsigned retro_api_version()
...@@ -185,6 +203,8 @@ extern "C" ...@@ -185,6 +203,8 @@ extern "C"
retro_log_callback logger; retro_log_callback logger;
if (e(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logger)) if (e(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logger))
env.logger = logger.log; 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; } void retro_set_video_refresh(retro_video_refresh_t callback) { env.video = callback; }
...@@ -338,41 +358,32 @@ extern "C" ...@@ -338,41 +358,32 @@ extern "C"
/* manage input */ /* manage input */
{ {
struct BtPair { const static int16_t mapping[retro8::BUTTON_COUNT] = {
unsigned player; RETRO_DEVICE_ID_JOYPAD_LEFT,
int16_t rabt; RETRO_DEVICE_ID_JOYPAD_RIGHT,
size_t r8bt; RETRO_DEVICE_ID_JOYPAD_UP,
bool isSet; RETRO_DEVICE_ID_JOYPAD_DOWN,
RETRO_DEVICE_ID_JOYPAD_A,
RETRO_DEVICE_ID_JOYPAD_B,
}; };
static bool btnState[retro8::PLAYER_COUNT][retro8::BUTTON_COUNT];
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
env.inputPoll(); 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); for (unsigned r8bt = 0; r8bt < retro8::BUTTON_COUNT; r8bt++)
const bool wasSet = entry.isSet; {
const bool isSet = env.inputState(player, RETRO_DEVICE_JOYPAD, 0, mapping[r8bt]);
const bool wasSet = btnState[player][r8bt];
if (wasSet != isSet) if (wasSet != isSet)
input.manageKey(entry.player, entry.r8bt, isSet); input.manageKey(player, r8bt, isSet);
entry.isSet = isSet; btnState[player][r8bt] = isSet;
} }
input.tick(); input.tick();
}
} }
} }
......
...@@ -73,7 +73,7 @@ namespace retro8 ...@@ -73,7 +73,7 @@ namespace retro8
}; };
static color_t colorForRGB(uint32_t color) static inline color_t colorForRGB(uint32_t color)
{ {
switch (color & 0x00ffffff) switch (color & 0x00ffffff)
{ {
......
...@@ -225,7 +225,6 @@ int palt(lua_State* L) ...@@ -225,7 +225,6 @@ int palt(lua_State* L)
{ {
color_t c = color_t(int(lua_tonumber(L, 1))); color_t c = color_t(int(lua_tonumber(L, 1)));
int f = lua_toboolean(L, 2); int f = lua_toboolean(L, 2);
palette_index_t index = gfx::DRAW_PALETTE_INDEX;
machine->memory().paletteAt(gfx::DRAW_PALETTE_INDEX)->transparent(c, f); machine->memory().paletteAt(gfx::DRAW_PALETTE_INDEX)->transparent(c, f);
} }
...@@ -845,7 +844,7 @@ namespace platform ...@@ -845,7 +844,7 @@ namespace platform
int32_t length = lua_tonumber(L, 3); int32_t length = lua_tonumber(L, 3);
if (length > 0) if (length > 0)
std::memset(machine->memory().base() + addr, 0, length); std::memset(machine->memory().base() + addr, value, length);
return 0; return 0;
} }
......
...@@ -183,7 +183,6 @@ void Machine::circfill(coord_t xc, coord_t yc, amount_t r, color_t color) ...@@ -183,7 +183,6 @@ void Machine::circfill(coord_t xc, coord_t yc, amount_t r, color_t color)
float d = 3 - 2 * r; float d = 3 - 2 * r;
circFillHelper(xc, yc, x, y, color); circFillHelper(xc, yc, x, y, color);
int ctr = 0;
while (y >= x) while (y >= x)
{ {
x++; x++;
......
...@@ -405,9 +405,6 @@ void APU::renderSounds(int16_t* dest, size_t totalSamples) ...@@ -405,9 +405,6 @@ void APU::renderSounds(int16_t* dest, size_t totalSamples)
{ {
handleCommands(); handleCommands();
constexpr size_t rate = 44100;
constexpr int16_t maxVolume = 4096;
memset(dest, 0, sizeof(int16_t)*totalSamples); memset(dest, 0, sizeof(int16_t)*totalSamples);
for (size_t i = 0; i < CHANNEL_COUNT; ++i) for (size_t i = 0; i < CHANNEL_COUNT; ++i)
......
...@@ -228,7 +228,7 @@ namespace retro8 ...@@ -228,7 +228,7 @@ namespace retro8
public: 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(); 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