Codes
WiiRd forum
June 18, 2024, 06:31:00 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome on the new server

Update 4.3 - do NOT update!
Gecko 1.9.3.1
Should I get a USB Gecko, I wanna hack?
How do I use my USB Gecko
Where can I get WiiRd?
 
   Home   CODE DATABASE GAMEHACKING Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Using Gecko version number to identify Wii/GC  (Read 2158 times)
WiiPower
Hacker
Sr. Member
*****

Karma: 23
Posts: 288


« on: May 14, 2011, 08:21:44 PM »

There's this in the code handler source:
Code:
#***************************************************************************
#                        subroutine: version number
#                Sends back the current gecko version number.
#***************************************************************************

versionnumber:
li r3, 0x80 #0x80 = Wii, 0x81 = NGC
bl exisendbyte
#b finish

When i run the code handler on a Wii in GC mode and set it to 0x81, Wiird does not recognize the version and freezes. 0x80 works fine.

Now my questions are:
Does Gecko dotNET like the 0x81 value?
Does Gecko dotNET block mem2 access when it knows it's running in gamecube mode?
Is there another way for Gecko dotNET to identify if it's Wii mode or GC mode? [I suppose it could be done via the disc id and/or the magic word that's in 0x80000000-0x80000020. And with auto detection, the code handler could be backwards compatible with Wiird while allowing this comfort] Or does it already do that?

Please don't shout if Gecko dotNET already handles it, i haven't had time yet to install and test it. I don't actually have much use for it anyways.
Logged
dcx2
Computer Engineer
Moderator
Legendary Member
*****

Karma: 165
Posts: 3468


WWW
« Reply #1 on: May 14, 2011, 08:35:01 PM »

When Gecko.NET checks the version number, it does a >= check.  So 0x80 and 0x81 will both work.  However, the only time version is checked is to determine whether Exact BP is supported and whether floats are reported when you GetRegisters.

I don't think it blocks mem2 access.  However, there's supposed to be some hidden 7F range, and Gecko.NET can allow access to that range, but I've never tested it.

I don't know of any way to identify Wii or GC mode.  If you can give me a magic address that holds the magic word, I can integrate that support into Gecko.NET, and I can also block access to MEM2 in GC Mode if that would help.
Logged

WiiPower
Hacker
Sr. Member
*****

Karma: 23
Posts: 288


« Reply #2 on: May 14, 2011, 10:03:47 PM »

It should be detectable by this:
0x80000018    4    0x5D1C9EA3    Disc layout magic (Wii)
0x8000001C    4    0xC2339F3D    Disc layout magic (GC)

But i can't say for sure it's still in memory after loading the game. I would check for the GC magic, if it's there GC mode, if not wii mode. Even if the magic word should be deleted, this way nothing should go worse than it does now.

What's this "Exact BP"? Is it limited to a certain code handler or is it limited to running on a wii or gc? I was planning to leave the version value on 0x80 in the next Gecko OS mod version for Wiird backwards compatiblity.

Edit: After a quick check with Wind Waker i'd say it looks good, 0xC2339F3D    @0x8000001C in memory
« Last Edit: May 14, 2011, 10:10:19 PM by WiiPower » Logged
dcx2
Computer Engineer
Moderator
Legendary Member
*****

Karma: 165
Posts: 3468


WWW
« Reply #3 on: May 14, 2011, 10:23:09 PM »

heh, my gf is playing Wind Waker right this minute.

What is Exact BP?  It's a feature of the code handler; it's in the source that we have available.  You can set a BP for exact with a checkbox in WiiRDGUI and Gecko.NET's breakpoint tabs.

The problem with "regular breakpoints" is that the PPC uses 8-byte alignment for detecting a read or write breakpoint.  So if you set a read breakpoint on 80000018, and some instruction reads 8000001C, your breakpoint will hit both.  This causes a lot of false positives.

So whoever wrote this code handler decided to extend the BP functionality.  If the BP was marked "exact" when it was set, then it forces 1-byte alignment with the address.  That is, if you set it for read BP on 80000018, then it would break ONLY if the address being read was 80000018.  This check is inside the code handler before WiiRDGUI or Gecko.NET are even aware of a BP so it is very fast

Unfortunately, if it lhz's 8000001A, the Exact BP won't hit, because 8000001A != 80000018.  And non-exact BP would hit any reads for 8000001C-8000001F.

That's why Gecko.NET has a checkbox for "skip unaligned BP".  If exact is not checked, it effectively enforces a 4-byte alignment for breakpoints, but this check is outside the code handler so it is not as fast.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!