-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
pub fn identify_mgba() -> bool {
const REG_MGBA_ENABLE: *mut u16 = 0x04FFF780 as *mut u16;
let original_value = unsafe { read_volatile(REG_MGBA_ENABLE) };
unsafe {
write_volatile(REG_MGBA_ENABLE, 0xC0DE);
let result = read_volatile(REG_MGBA_ENABLE) == 0x1DEA;
write_volatile(REG_MGBA_ENABLE, original_value); // Restore original value
result
}
}I haven't tested the code, but by looking at it I noticed you're reading the register's value and then writing the same value again. But the debug enable register, when read, does not return '0xc0de', but instead '0x1dea' or any other value.
So when restoring the register, it should look something like this:
if original_value == 0xidea:
write 0xc0de to REG_MGBA_ENABLE // or do nothing, since the register has just been enabled during the test
else
write 0 to REG_MGBA_ENABLE
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels