Skip to content

Commit

Permalink
Add 2 more slots for Power Discs on Infinity Base
Browse files Browse the repository at this point in the history
  • Loading branch information
deReeperJosh authored and elad335 committed May 21, 2024
1 parent afa7a27 commit 3ba4c8a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
35 changes: 28 additions & 7 deletions rpcs3/Emu/Io/Infinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,24 @@ infinity_figure& infinity_base::get_figure_by_order(u8 order_added)

u8 infinity_base::derive_figure_position(u8 position)
{
while (position > 2)
position -= 2;

position++;
return position;
switch (position)
{
case 0:
case 1:
case 2:
return 1;
case 3:
case 4:
case 5:
return 2;
case 6:
case 7:
case 8:
return 3;

default:
return 0;
}
}

void infinity_base::query_block(u8 fig_num, u8 block, std::array<u8, 32>& reply_buf, u8 sequence)
Expand Down Expand Up @@ -265,9 +278,13 @@ bool infinity_base::remove_figure(u8 position)

if (figure.present)
{
figure.present = false;

position = derive_figure_position(position);
if (position == 0)
{
return false;
}

figure.present = false;

std::array<u8, 32> figure_change_response = {0xab, 0x04, position, 0x09, figure.order_added,
0x01};
Expand Down Expand Up @@ -329,6 +346,10 @@ u32 infinity_base::load_figure(const std::array<u8, 0x14 * 0x10>& buf, fs::file
order_added = figure.order_added;

position = derive_figure_position(position);
if (position == 0)
{
return 0;
}

std::array<u8, 32> figure_change_response = {0xab, 0x04, position, 0x09, order_added, 0x00};
figure_change_response[6] = generate_checksum(figure_change_response, 6);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Io/Infinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class infinity_base

protected:
shared_mutex infinity_mutex;
std::array<infinity_figure, 7> figures;
std::array<infinity_figure, 9> figures;

private:
u8 generate_checksum(const std::array<u8, 32>& data, int num_of_bytes) const;
Expand Down
21 changes: 13 additions & 8 deletions rpcs3/rpcs3qt/infinity_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <QCompleter>

infinity_dialog* infinity_dialog::inst = nullptr;
std::array<std::optional<u32>, 7> infinity_dialog::figure_slots = {};
std::array<std::optional<u32>, 9> infinity_dialog::figure_slots = {};
static QString s_last_figure_path;

LOG_CHANNEL(infinity_log, "infinity");
Expand Down Expand Up @@ -426,8 +426,9 @@ figure_creator_dialog::figure_creator_dialog(QWidget* parent, u8 slot)
// Only display entry if it is a piece appropriate for the slot
if ((slot == 0 &&
((figure > 0x1E8480 && figure < 0x2DC6BF) || (figure > 0x3D0900 && figure < 0x4C4B3F))) ||
((slot == 1 || slot == 2) && figure < 0x1E847F) ||
((slot == 3 || slot == 4 || slot == 5 || slot == 6) &&
((slot == 1 || slot == 2) && (figure > 0x3D0900 && figure < 0x4C4B3F)) ||
((slot == 3 || slot == 6) && figure < 0x1E847F) ||
((slot == 4 || slot == 5 || slot == 7 || slot == 8) &&
(figure > 0x2DC6C0 && figure < 0x3D08FF)))
{
const u32 qnum = (figure << 8) | entry.second.first;
Expand Down Expand Up @@ -681,17 +682,21 @@ infinity_dialog::infinity_dialog(QWidget* parent)

add_figure_slot(vbox_group, QString(tr("Play Set/Power Disc")), 0);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player One")), 1);
add_figure_slot(vbox_group, QString(tr("Power Disc Two")), 1);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player One Ability One")), 3);
add_figure_slot(vbox_group, QString(tr("Power Disc Three")), 2);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player One")), 3);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player One Ability One")), 4);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player One Ability Two")), 5);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player Two")), 2);
add_figure_slot(vbox_group, QString(tr("Player Two")), 6);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player Two Ability One")), 4);
add_figure_slot(vbox_group, QString(tr("Player Two Ability One")), 7);
add_line(vbox_group);
add_figure_slot(vbox_group, QString(tr("Player Two Ability Two")), 6);
add_figure_slot(vbox_group, QString(tr("Player Two Ability Two")), 8);

group_figures->setLayout(vbox_group);
vbox_panel->addWidget(group_figures);
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/infinity_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class infinity_dialog : public QDialog
void load_figure_path(u8 slot, const QString& path);

protected:
std::array<QLineEdit*, 7> m_edit_figures{};
static std::array<std::optional<u32>, 7> figure_slots;
std::array<QLineEdit*, 9> m_edit_figures{};
static std::array<std::optional<u32>, 9> figure_slots;

private:
void add_figure_slot(QVBoxLayout* vbox_group, QString name, u8 slot);
Expand Down

0 comments on commit 3ba4c8a

Please sign in to comment.