Skip to content

Commit

Permalink
Make Wii + PS3 crossplay work
Browse files Browse the repository at this point in the history
  • Loading branch information
ihatecompvir committed Sep 22, 2024
1 parent 72d49f6 commit 64894f1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
1 change: 0 additions & 1 deletion include/CrossplayHooks.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "rb3/BinStream.h"

extern void MessageBrokerDDL(unsigned int doClassID);
void MessageBrokerDDLHook(unsigned int doClassID);
BinStream *OnlineIDReadHook(BinStream *thisBinStream, void *onlineID);
BinStream *OnlineIDWriteHook(BinStream *thisBinStream, void *onlineID);
BinStream *WriteUsernameHook(BinStream *thisBinStream, char *username);
19 changes: 17 additions & 2 deletions include/ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
#define PORT_STAGEKIT_EXISTS 0x8228d03c // StageKit check. nop over to allow for fog command without a physical StageKit connected.
#define PORT_VERTEX_READ_1 0x82418704 // call to Vector3::operator>> to read vertex position
#define PORT_VERTEX_READ_2 0x82418748 // call to Vector3::operator>> to read vertex normals
#define PORT_MESSAGEBROKERDDL 0x823f45d0 // force MessageBrokerDDL to get registered with ID 0x24
#define PORT_IDGENERATORDDL 0x82aa04c4 // force IDGeneratorDDL to get registered with ID 0x05
#define PORT_PROMOTIONREFEREEDDL 0x82aa04d4 // force PromotionRefereeDDL to get registered with ID 0x06
#define PORT_ROOTDODDL 0x82aa04e0 // force RootDODDL to get registered with ID 0x02
#define PORT_SESSIONDDL 0x82aa04f0 // force SessionDDL to get registered with ID 0x04
#define PORT_STATIONDDL 0x82aa0500 // force StationDDL to get registered with ID 0x03
#define PORT_SESSIONCLOCKDDL 0x82b267dc // force SessionClockDDL to get registered with ID 0x12
#define PORT_DEFAULTCELLDDL 0x82b2674c // force DefaultCellDDL to get registered with ID 0x0c
// function patch addresses
#define PORT_SETDISKERROR 0x82516320 // PlatformMgr::SetDiskError
#define PORT_APP_RUN 0x82272e90 // App::Run
Expand Down Expand Up @@ -135,7 +143,6 @@
#define PORT_BINSTREAMREADENDIAN 0x827c5058 // BinStream::ReadEndian
#define PORT_BINSTREAMWRITEENDIAN 0x827c5098 // BinStream::WriteEndian
#define PORT_BINSTREAMWRITELENGTHSTRING 0x827c5100 // BinStream::WriteLengthString
#define PORT_MESSAGEBROKERDDL 0x823f4498 // MessageBrokerDDL
#define PORT_ONLINEIDREAD 0x82523e80 // OnlineID::operator<<
#define PORT_ONLINEIDWRITE 0x82523a24 // OnlineID::operator>>
#define PORT_WRITEUSERNAME 0x82523a18 // BinStream::WriteLengthString call that writes username into userdata
Expand Down Expand Up @@ -202,6 +209,15 @@ void DbgPrint(const char *s, ...);
#define PORT_MICCHECK 0x8024a4e8 // a bne that throws an error on the song select screen if the mic is not connected
#define PORT_BIGSYMBOLFUNC_TAIL 0x8037a3d4 // blr after a function that initialises a bunch of symbols
#define PORT_UPDATEPRESENCEBLOCK_B 0x80188194 // branch after the failure case in a function that calls UpdatePresence
#define PORT_MESSAGEBROKERDDL 0x800bc4bc // force MessageBrokerDDL to get registered with ID 36
#define PORT_IDGENERATORDDL 0x80053efc // force IDGeneratorDDL to get registered with ID 0x05
#define PORT_PROMOTIONREFEREEDDL 0x80053f08 // force PromotionRefereeDDL to get registered with ID 0x06
#define PORT_ROOTDODDL 0x80053f10 // force RootDODDL to get registered with ID 0x02
#define PORT_SESSIONDDL 0x80053f1c // force SessionDDL to get registered with ID 0x04
#define PORT_STATIONDDL 0x80053f28 // force StationDDL to get registered with ID 0x03
#define PORT_SESSIONCLOCKDDL 0x80083768 // force SessionClockDDL to get registered with ID 0x12
#define PORT_DEFAULTCELLDDL 0x8007e004 // force DefaultCellDDL to get registered with ID 0x0c
#define PORT_VOICECHANNELDDL 0x80088a34
// #define PORT_LOADOBJS_BCTRL 0x827562e4
// function patch addresses
#define PORT_SETDISKERROR 0x8030ce7c // PlatformMgr::SetDiskError
Expand Down Expand Up @@ -270,7 +286,6 @@ void DbgPrint(const char *s, ...);
#define PORT_BINSTREAMWRITEENDIAN 0x80343190 // BinStream::WriteEndian
#define PORT_BINSTREAMWRITELENGTHSTRING 0x80342ad8 // BinStream::WriteLengthString
#define PORT_PROPSYNCBOOL 0x800fd3d4 // PropSync::Bool
#define PORT_MESSAGEBROKERDDL 0x800bcbd8 // MessageBrokerDDL
#define PORT_BANDUSERSYNCSAVE 0x800fc408 // BandUser::SyncSave
#define PORT_USERSYNCSAVE 0x803117d4 // User::SyncSave
#define PORT_REMOTEBANDUSERSYNCLOAD 0x800fe6fc // RemoteBandUser::SyncLoad
Expand Down
38 changes: 25 additions & 13 deletions source/rb3enhanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,27 +335,39 @@ void InitialiseFunctions()

void ApplyCrossplayHooks()
{
// we need to hook the function that gets the MessageBroker's ID so we can ensure its the same on Wii and 360
HookFunction(PORT_MESSAGEBROKERDDL, &MessageBrokerDDL, &MessageBrokerDDLHook);
// patches so DDLs get registered with the same IDs on all platforms
// these could be anything in theory, but use the values from PS3/Wii
POKE_32(PORT_MESSAGEBROKERDDL, LI(3, 0x24));
POKE_32(PORT_IDGENERATORDDL, LI(3, 0x05));
POKE_32(PORT_PROMOTIONREFEREEDDL, LI(3, 0x06));
POKE_32(PORT_ROOTDODDL, LI(3, 0x02));
POKE_32(PORT_SESSIONDDL, LI(3, 0x04));
POKE_32(PORT_STATIONDDL, LI(3, 0x03));
POKE_32(PORT_SESSIONCLOCKDDL, LI(3, 0x12));
POKE_32(PORT_DEFAULTCELLDDL, LI(3, 0x0c));

POKE_BL(PORT_ONLINEIDREAD, &OnlineIDReadHook);
POKE_BL(PORT_ONLINEIDWRITE, &OnlineIDWriteHook);
POKE_BL(PORT_WRITEUSERNAME, &WriteUsernameHook);

#ifdef RB3E_WII // wii exclusive hooks

// voice chat is only on wii, so no need to change it for 360
POKE_32(PORT_VOICECHANNELDDL, LI(3, 0x18));

HookFunction(PORT_PROPSYNCBOOL, &PropSyncBool, &PropSyncBoolHook); // hook to restore Wii venue intros for crossplay

// kill voice chat registration (for now, we shouldn't sacrifice voice chat in the final version)
// likely we can do some hooks for getting/setting the IDs for these so they are safely out of the range that 360 would ever use
// so wiis can still use and exchange voice chat packets, but 360 will just ignore them
POKE_32(0x80087164, NOP);
POKE_32(0x80087188, NOP);
POKE_32(0x800871ac, NOP);
POKE_32(0x800871d0, NOP);
POKE_32(0x800871f4, NOP);
POKE_32(0x80087218, NOP);
POKE_32(0x8008723c, NOP);
POKE_32(0x80087260, NOP);
// comp note: commented this out, for crossplay to work on 360 this will need to be re-added
// 360 does not have voice chat through quazal stuff, so we'll need to fix up the ids for every non-voice chat duplicated object method on 360 so they match ps3 + wii
// -------------------
// POKE_32(0x80087164, NOP);
// POKE_32(0x80087188, NOP);
// POKE_32(0x800871ac, NOP);
// POKE_32(0x800871d0, NOP);
// POKE_32(0x800871f4, NOP);
// POKE_32(0x80087218, NOP);
// POKE_32(0x8008723c, NOP);
// POKE_32(0x80087260, NOP);

// kill flow request registration (its completely unused anyway, not sure what the purpose was)
POKE_32(0x8021f974, NOP);
Expand Down

0 comments on commit 64894f1

Please sign in to comment.