Skip to content

Commit

Permalink
Merge pull request #721 from rickgaiser/mx4sio
Browse files Browse the repository at this point in the history
Try to make MCEMU/VMC compatible with MX4SIO
  • Loading branch information
uyjulian committed Aug 9, 2022
2 parents 96eb7eb + e3d5bed commit 7d786b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/mcemu/mcemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ void InstallSecrmanHook(void *exp)
/* Installs handlers for SIO2MAN's routine for enabled virtual memory cards */
void InstallSio2manHook(void *exp, int ver)
{
psio2_mc_transfer_init = GetExportEntry(exp, 24);
psio2_transfer_reset = GetExportEntry(exp, 26);

/* hooking SIO2MAN entry #25 (used by MCMAN and old PADMAN) */
pSio2man25 = HookExportEntry(exp, 25, hookSio2man25);
/* hooking SIO2MAN entry #51 (used by MC2_* modules and PADMAN) */
Expand Down Expand Up @@ -459,6 +462,12 @@ u32 *hookSio2man67()
/* SIO2 Command handler */
void Sio2McEmu(Sio2Packet *sd)
{
/*
* Unlock SIO2 access for MX4SIO
* NOTE: we are assuming MC's are only accessed when LOCKED
*/
psio2_transfer_reset();

if ((sd->ctrl[0] & 0xF0) == 0x70) {
register u32 ddi, *pctl, result, length;
register u8 *wdma, *rdma;
Expand Down Expand Up @@ -591,6 +600,12 @@ void Sio2McEmu(Sio2Packet *sd)
}

/* DPRINTF("SIO2 status 0x%X\n", sd->iostatus); */

/*
* Lock SIO2 access again as the user expects it
* NOTE: we are assuming MC's are only accessed when LOCKED
*/
psio2_mc_transfer_init();
}
//------------------------------
// endfunc
Expand Down
2 changes: 2 additions & 0 deletions modules/mcemu/mcemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef struct _MemoryCard

/* type for a pointer to SIO2MAN's entries */
typedef void (*Sio2McProc)(Sio2Packet *arg);
typedef void (*Sio2McProc2)();

int DummySecrAuthCard(int port, int slot, int cnum);
void Sio2McEmu(Sio2Packet *sd);
Expand Down Expand Up @@ -208,6 +209,7 @@ extern void *pFastBuf;

extern PtrRegisterLibraryEntires pRegisterLibraryEntires;
extern Sio2McProc pSio2man25, pSio2man51;
extern Sio2McProc2 psio2_mc_transfer_init, psio2_transfer_reset;
extern void (*pSio2man67)();

extern u8 mceccbuf[MCEMU_PORTS][0x20];
Expand Down
1 change: 1 addition & 0 deletions modules/mcemu/mcemu_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void *pFastBuf = NULL;

PtrRegisterLibraryEntires pRegisterLibraryEntires; /* Pointer to RegisterLibraryEntires routine */
Sio2McProc pSio2man25, pSio2man51; /* Pointers to SIO2MAN routines */
Sio2McProc2 psio2_mc_transfer_init, psio2_transfer_reset;
void (*pSio2man67)();

u8 mceccbuf[MCEMU_PORTS][0x20]; /* ECC buffers */
Expand Down

0 comments on commit 7d786b3

Please sign in to comment.