| 142 | } |
| 143 | |
| 144 | void Sio0::SetTxData(u8 cmd) |
| 145 | { |
| 146 | Sio0Log.WriteLn("%s()\tSIO0 TX_DATA Write\t(%02X)", __FUNCTION__, cmd); |
| 147 | |
| 148 | stat |= SIO0_STAT::TX_READY | SIO0_STAT::TX_EMPTY; |
| 149 | stat |= (SIO0_STAT::RX_FIFO_NOT_EMPTY); |
| 150 | |
| 151 | if (!(ctrl & SIO0_CTRL::TX_ENABLE)) |
| 152 | { |
| 153 | Console.Warning("%s(%02X) CTRL in illegal state, exiting instantly", __FUNCTION__, cmd); |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | txData = cmd; |
| 158 | u8 data = 0; |
| 159 | PadBase* currentPad = nullptr; |
| 160 | |
| 161 | switch (sioMode) |
| 162 | { |
| 163 | case SioMode::NOT_SET: |
| 164 | sioMode = cmd; |
| 165 | currentPad = Pad::GetPad(port, slot); |
| 166 | currentPad->SoftReset(); |
| 167 | mcd = &mcds[port][slot]; |
| 168 | SetAcknowledge(true); |
| 169 | break; |
| 170 | case SioMode::PAD: |
| 171 | currentPad = Pad::GetPad(port, slot); |
| 172 | pxAssertMsg(currentPad != nullptr, "Got nullptr when looking up pad"); |
| 173 | // Set ACK in advance of sending the command to the pad. |
| 174 | // The pad will, if the command is done, set ACK to false. |
| 175 | SetAcknowledge(true); |
| 176 | data = currentPad->SendCommandByte(cmd); |
| 177 | SetRxData(data); |
| 178 | break; |
| 179 | case SioMode::MEMCARD: |
| 180 | if (this->sioCommand == MemcardCommand::NOT_SET) |
| 181 | { |
| 182 | if (IsMemcardCommand(cmd) && mcd->IsPresent() && mcd->IsPSX()) |
| 183 | { |
| 184 | this->sioCommand = cmd; |
| 185 | SetAcknowledge(true); |
| 186 | SetRxData(this->flag); |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | SetAcknowledge(false); |
| 191 | SetRxData(0x00); |
| 192 | } |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | SetRxData(Memcard(cmd)); |
| 197 | } |
| 198 | break; |
| 199 | default: |
| 200 | SetRxData(0xff); |
| 201 | SetAcknowledge(false); |
no test coverage detected