Supporting arkanoid controllers now

This commit is contained in:
SergioMartin86 2024-08-08 17:54:55 +02:00
parent 29beac9732
commit afc0c273c5
3 changed files with 3507 additions and 6 deletions

View File

@ -122,8 +122,8 @@ class InputParser
parseConsoleInputs(input.reset, input.power, ss, inputString); parseConsoleInputs(input.reset, input.power, ss, inputString);
// Parsing controller 1 inputs // Parsing controller 1 inputs
if (_controller1Type == arkanoidNES) parseArkanoidInput(input, ss, inputString); if (_controller1Type == arkanoidNES) parseArkanoidNESInput(input, ss, inputString);
if (_controller1Type == arkanoidFamicom) parseArkanoidInput(input, ss, inputString); if (_controller1Type == arkanoidFamicom) parseArkanoidFamicomInput(input, ss, inputString);
if (_controller1Type == joypad || _controller1Type == fourscore1) parseControllerInputs(_controller1Type, input.port1, ss, inputString); if (_controller1Type == joypad || _controller1Type == fourscore1) parseControllerInputs(_controller1Type, input.port1, ss, inputString);
// Parsing controller 2 inputs // Parsing controller 2 inputs
@ -304,6 +304,28 @@ class InputParser
} }
} }
static inline void parseArkanoidNESInput(input_t& input, std::istringstream& ss, const std::string& inputString)
{
// Simply parse the arkanoid controller input
parseArkanoidInput(input, ss, inputString);
}
static inline void parseArkanoidFamicomInput(input_t& input, std::istringstream& ss, const std::string& inputString)
{
// Parsing joypad controller
parseControllerInputs(controller_t::joypad, input.port1, ss, inputString);
// Controller separator
if (ss.get() != '|') reportBadInputString(inputString);
// Advancing 7 positions (this input is not supported)
for (size_t i = 0; i < 7; i++) if (ss.get() != '.') reportBadInputString(inputString);
// Then, parse the arkanoid controller input
parseArkanoidInput(input, ss, inputString);
}
static void parseConsoleInputs(bool &reset, bool &power, std::istringstream &ss, const std::string &inputString) static void parseConsoleInputs(bool &reset, bool &power, std::istringstream &ss, const std::string &inputString)
{ {
// Currently read character // Currently read character

View File

@ -746,7 +746,7 @@ class Core : private Cpu
if (addr == 0x4017) if (addr == 0x4017)
{ {
// latch 0 encodes fire, latch 1 encodes potentiometer // latch 0 encodes fire, latch 1 encodes potentiometer
const uint8_t result = (input_state.arkanoid_latch & 1) * 16 + current_arkanoid_fire * 8; const uint8_t result = (input_state.arkanoid_latch & 1) * 16 + input_state.arkanoid_fire * 8;
// Advancing latch 1 // Advancing latch 1
input_state.arkanoid_latch >>= 1; input_state.arkanoid_latch >>= 1;
@ -759,17 +759,24 @@ class Core : private Cpu
if (addr == 0x4016) if (addr == 0x4016)
{ {
// latch 0 encodes fire // latch 0 encodes fire
const uint8_t result = (input_state.joypad_latches[0] & 1) * 2; uint8_t result = (input_state.arkanoid_fire & 1) * 2;
// latch 0 also encodes joypad 1
result += (input_state.joypad_latches[0] & 1) & 1;
// Advancing joypad latch
input_state.joypad_latches[0] >>= 1;
return result; return result;
} }
if (addr == 0x4017) if (addr == 0x4017)
{ {
// latch 1 encodes potentiometer // latch 1 encodes potentiometer
const uint8_t result = (input_state.joypad_latches[1] & 1) * 2; const uint8_t result = (input_state.arkanoid_latch & 1) * 2;
// Advancing latch 1 // Advancing latch 1
input_state.joypad_latches[1] >>= 1; input_state.arkanoid_latch >>= 1;
return result; return result;
} }
} }

File diff suppressed because it is too large Load Diff