Skip to content

Add Emulator checks to the USB library to prevent crashes on emulators #60

@buu342

Description

@buu342

Due to the EverDrive check requiring that a register is written to (which is by design and unlikely to change), it can lead to emulators crashing. A check for whether the ROM is running on an emulator should therefore be added to the start of usb_initialize() to prevent further issues.

This can be done in multiple ways:

  1. On emulators, the RDP clock register is always zero (IO_READ(DPC_CLOCK_REG)) unless written to specifically by a game.
  2. You can check how often the counter register increments, but that fails on MUPEN.
  3. You can purposefully trigger an icache miss and measure the counter to see if the CPU stalled, but that requires very specific address alignment
  4. Overwrite the start of a function right before it executes without any cache invalidation. This is the method used by Marshall on his MGC 2011 demo.

It would be probably best to attempt method 1, and then fall back on a second method just in case.

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingImplementedThis has been fixed but not yet published/pushedUSB LibraryThis is related to the USB library (usb.c)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions