Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 543
» Latest member: Zacku
» Forum threads: 1,663
» Forum posts: 11,943

Full Statistics

Online Users
There are currently 228 online users.
» 0 Member(s) | 223 Guest(s)
Applebot, Bing, Facebook, Google, Yandex

Latest Threads
Make it to 10,000
Forum: General Discussion
Last Post: Vega
5 hours ago
» Replies: 5,680
» Views: 4,187,610
Boot into TT cup selectio...
Forum: Misc/Other
Last Post: Vega
9 hours ago
» Replies: 3
» Views: 2,867
Request: Custom brsars pe...
Forum: Code Support / Help / Requests
Last Post: lschlick
04-25-2024, 05:45 PM
» Replies: 0
» Views: 31
E-mails not working on th...
Forum: General Discussion
Last Post: Fifty
04-19-2024, 04:56 AM
» Replies: 3
» Views: 245
More missing info from Br...
Forum: Coding & Hacking General Discussion
Last Post: Vega
04-15-2024, 10:04 PM
» Replies: 0
» Views: 184
Request: Custom music vol...
Forum: Code Support / Help / Requests
Last Post: lschlick
04-15-2024, 06:13 PM
» Replies: 0
» Views: 198
Request: Additional sound...
Forum: Code Support / Help / Requests
Last Post: _Ro
04-15-2024, 01:50 AM
» Replies: 6
» Views: 241
Mistake in the Broadway M...
Forum: Coding & Hacking General Discussion
Last Post: Vega
04-14-2024, 11:58 PM
» Replies: 0
» Views: 97
Camera Distance Modifier ...
Forum: Visual & Sound Effects
Last Post: vlonebozo
04-13-2024, 11:05 PM
» Replies: 1
» Views: 6,765
Pretty In Game Item Spy p...
Forum: Online; Item
Last Post: vlonebozo
04-13-2024, 03:52 PM
» Replies: 1
» Views: 585

 
  Request: Custom brsars per-track
Posted by: lschlick - 04-25-2024, 05:45 PM - Forum: Code Support / Help / Requests - No Replies

There are some custom tracks that would benefit greatly from having custom sound effects. For example, there are a few custom tracks I have seen lately with these custom bird objects that fly away when you get close to them. Oddly enough, they sound like the Nokis from Super Mario Sunshine, because that's the sound that they default to. If I were to replace the Noki voices in the brsar with bird chirping, it may fix the issue, but then we have the issue of the actual Nokis (in tracks such as GCN Peach Beach) now making bird chirping sounds instead of their regular voices. Then there are also lots of custom tracks that just kind of feel "dead" in the sense that they are lack atmosphere. And the sound effects that would be required to give them atmosphere don't exist in the default brsar.

To fix this problem, here is the code I am requesting.

If a custom track .szs file contains a brsar file, then any entries in that brsar file should override the default ones when that track is loaded. Since an entire brsar is quite large (~ 100 MB compared to ~ 3 MB for a typical custom track), the custom brsar should only contain the brsar entries you want to override.

To use this code: When you open a brsar in BrawlCrate, there are two panels you can see. On the left, there are entries organized within a tree-like structure with folders. On the right, there is a separate list of entries sorted by index. If you want to replace entries in the left panel with custom entries, then in your custom brsar you would delete all entries and folders in the left panel except for the ones making up the paths of the entries you want to edit. If you want to replace entries in the right panel, then in your custom brsar you would delete all entries in the right panel except the ones you want to edit. Once you have made all the edits you want to make, save the brsar and then add it to your custom track folder, then use wszst to build the folder into a .szs file.

Print this item

  E-mails not working on this forum
Posted by: seanmcnally - 04-17-2024, 09:23 PM - Forum: General Discussion - Replies (3)

Hey there,

This might be an issue you guys are already aware of, but it seems e-mail notifications aren't working for subscribed threads on this forum.  I double checked my spam folder, nothing there either.

Print this item

  More missing info from Broadway Manual (lfd & stfd)
Posted by: Vega - 04-15-2024, 10:04 PM - Forum: Coding & Hacking General Discussion - No Replies

Expanding on my previous thread HERE about missing info in the Broadway Manual, it appears I've ran into some more omitted information of the 1.0 Version of the Broadway Manual. I was doing some real hardware tests of floating point loads and stores, so I can know how to code them into my Broadway PPC Instruction Simulator. Anyway, I was running into some weird results, but after some tinkering, I found out that not only does lfs+stfs operations varie on the HID2 PSE bit, so does lfd+stfd.

Here's what occurs~
lfs
PSE low: 32-bit Single Float loaded from EA. Converted to 64-bit form. Placed into fD
PSE high: 32-bit Single Float loaded from EA. Placed into both ps0 and ps1 of fD

lfd (PSE high stuff missing from Manual)
PSE low: 64-bit Double Float loaded from EA. Placed into fD
PSE high: 64-bit Double Float loaded from EA. Converted to 32-bit Single Precision. Placed into ps0 with ps1 being left undefined***

stfs
PSE low: Value in fS is converted to a 32-bit Single Precision float. That float is stored at EA.
PSE high: ps0 of fS stored at EA

stfd (PSE high stuff missing from Manual)
PSE low: fS stored at EA
PSE high: Value in fS's ps0 converted to 64-bit form. That 64-bit float is stored at EA.

***Tested a handful of numbers, and every time lfd was done (when HID2 PSE high), ps1 was always written as 0x3F800000. I doubt this is a "hardcoded" constant, most likely it's just undefined (junk).

Obviously, if there are data-type conversions (i.e. denorms), those still occur in accordance to what is stated in the Broadway Manual.

Here are two snippets of code that confirms this. These are hooked to the Shared Item Address and will only execute when HID2 PSE is high. I didn't want to set HID2 PSE manually because that requires I-Cache invalidation & disabling. Run these on a real Wii console as Dolphin will not emulate this correctly.

Snippet 1 does this:

  • Sets 0x40341000 00000000 in memory via GPRs
  • Uses lfd to load it
  • Stores it via stfs, psq_st, and stfd
  • Results of the 3 stores are printed to screen in that order

Snippet 2 does this:
  • Sets 0x40341000 00000000 in memory via GPRs
  • Uses lfs to load it
  • Stores it via stfs, psq_st, and stfd
  • Results of the 3 stores are printed to screen in that order

I am using the integer value 0x40341000 00000000 for the test because this is a normalized (valid) double-precision float. Also, if it is read as single (0x40341000), this is a normalized (valid) single-precision float. Since both these floats are normalized and the exponent bits are greater than 896, there are zero data-type conversions. Only conversions are the standard width/precision changes mentioned earlier which always occur.

Snippet 1 will result as:
41A08000 00000000 (41A08000 written from the stfs)
41A08000 3F800000 (written from the psq_st, this shows what was loaded via lfd, ps1 is most likely undefined/junk as explained earlier)
40341000 00000000 (stfd, this gets written because 41A08000 is converted to its 64-bit form)

Snippet 2 will result as:
40341000 00000000 (40341000 written from the stfs)
40341000 40341000 (written from psq_st, this shows what was loaded via lfs, ofc lfs loads same value into ps0 and ps1)
40068200 00000000 (stfd, this gets written because 40068200 is converted to its 64-bit form)

Here are the codes~

Snippet 1:
Code:
#C2 Address 807BA164
#Pick up box, see result on screen

.set doubleword1, 0x40341000
.set doubleword2, 0x00000000

.set HID2, 920
.set PSE, 0x2000 #low bits excluded

#Shared Item Default instruction
stw r3, 0x0020 (r23)

#Check PSE bit of HID2
mfspr r12, HID2
andis. r12, r12, PSE
beq- the_end

#Set r31 to 0x80001500
lis r31, 0x8000
ori r31, r31, 0x1500

#Set double word to store
lis r3, doubleword1@h
ori r3, r3, doubleword1@l
lis r4, doubleword2@h
ori r4, r4, doubleword2@l
stw r3, 0 (r31)
stw r4, 0x4 (r31)

#Prove lfd, stfs, and stfd
#Load float
lfd f1, 0 (r31) #Loads as 0x41A08000 3F800000

#Store float, stores as 0x41A08000
stfs f1, 0 (r31)

#Store paired single, stores as 0x41A08000 3F800000
psq_st f1, 0x8 (r31), 0, 0

#Store using stfd, will store as 40341000 00000000
stfd f1, 0x10 (r31)

#Load the fpr values for sprintf
lwz r5, 0 (r31)
lwz r6, 0x4 (r31)
lwz r7, 0x8 (r31)
lwz r8, 0xC (r31)
lwz r9, 0x10 (r31)
lwz r10, 0x14 (r31)

#Set r4 arg for sprintf
bl setsprintf
.asciz "%08X %08X\n%08X %08X\n%08X %08X"
.align 2
setsprintf:
mflr r4

#Set r3 arg for sprintf
addi r3, r31, 0x40

#Clear cr1 eq bit cuz no floats for sprintf
crclr 6

#Call sprintf
lis r12, 0x8001
ori r12, r12, 0x1A2C
mtctr r12
bctrl

addi r5, r31, 0x40

#Setup OSFatal args
bl setupfatal
.long 0xFFFFFFFF
.long 0
setupfatal:
mflr r3
addi r4, r3, 4

#Call OSFatal
lis r12, 0x801A
ori r12, r12, 0x4EC4
mtctr r12
bctr

the_end:


Snippet 2:
Code:
#C2 Address 807BA164
#Pick up box, see result on screen

.set doubleword1, 0x40341000
.set doubleword2, 0x00000000

.set HID2, 920
.set PSE, 0x2000 #low bits excluded

#Shared Item Default instruction
stw r3, 0x0020 (r23)

#Check PSE bit of HID2
mfspr r12, HID2
andis. r12, r12, PSE
beq- the_end

#Set r31 to 0x80001500
lis r31, 0x8000
ori r31, r31, 0x1500

#Set double word to store
lis r3, doubleword1@h
ori r3, r3, doubleword1@l
lis r4, doubleword2@h
ori r4, r4, doubleword2@l
stw r3, 0 (r31)
stw r4, 0x4 (r31)

#Prove lfs, stfs, and stfd
#Load float
lfs f1, 0 (r31) #Loads as 0x40341000 40341000

#Store float, stores as 0x40341000
stfs f1, 0 (r31)

#Store paired single, stores as 0x40341000 40341000
psq_st f1, 0x8 (r31), 0, 0

#Store using stfd, will store as 0x40068200 00000000
stfd f1, 0x10 (r31)

#Load the fpr values for sprintf
lwz r5, 0 (r31)
lwz r6, 0x4 (r31)
lwz r7, 0x8 (r31)
lwz r8, 0xC (r31)
lwz r9, 0x10 (r31)
lwz r10, 0x14 (r31)

#Set r4 arg for sprintf
bl setsprintf
.asciz "%08X %08X\n%08X %08X\n%08X %08X"
.align 2
setsprintf:
mflr r4

#Set r3 arg for sprintf
addi r3, r31, 0x40

#Clear cr1 eq bit cuz no floats for sprintf
crclr 6

#Call sprintf
lis r12, 0x8001
ori r12, r12, 0x1A2C
mtctr r12
bctrl

addi r5, r31, 0x40

#Setup OSFatal args
bl setupfatal
.long 0xFFFFFFFF
.long 0
setupfatal:
mflr r3
addi r4, r3, 4

#Call OSFatal
lis r12, 0x801A
ori r12, r12, 0x4EC4
mtctr r12
bctr

the_end:

In conclusion, now you know. If you find any of this incorrect, please let me know.

Print this item

  Request: Custom music volume reduction factor for Mushroom Gorge cave section
Posted by: lschlick - 04-15-2024, 06:13 PM - Forum: Code Support / Help / Requests - No Replies

In Mushroom Gorge, when you enter the cave, the volume of the music gets reduced. I would like a code which overrides the volume reduction factor. I assume it's fairly simple, you just need to locate the constant that determines the amount of volume reduction, and then replace it with a custom value.

There is a similar issue in N64 Sherbet Land. There are two different sound triggers that reduce the music volume by different amounts as you go deeper into the cave. A code for each of those would also be nice to have, though it's not as big a priority.

Print this item

  Mistake in the Broadway Manual regarding frsqrte
Posted by: Vega - 04-14-2024, 11:58 PM - Forum: Coding & Hacking General Discussion - No Replies

Most coders here are familiar with the Broadway Manual. If anybody has also read through it, you will find it littered with diagram mistakes and typoes. Considering it's a preliminary file that was never meant for the public, this is sort of expected.

However, I came across a decent mistake (or information left missing) regarding the description of the frsqrte instruction. I've been working on a Broadway PPC Instruction Simulator recently and have to make sure it's as accurate as possible. So I've been combing thru the manual at times.

According to the Broadway Manual (page 426), the frsqrte instruction does this~
1. frB used as input (64-bit input)
2. Reciprocal of Square Root Estimate is performed (within 1/4096 accuracy)
3. frD gets result as 64-bit

What's odd is that there is no mention about how the instruction operates in regards to the HID2 PSE bit. I've tried reading other Chapters, and there's nothing explicit. As an fyi, for every single-float instruction (except for fabs, fneg, and fnabs), the operation of said instruction varies depending on whether PSE bit is low or high.

For example, the fmr instruction.
When HID2 PSE is low
1. Entire Value of frB is copied to frD
When HID2 PSE is high
2. ps0 of frB copied to ps0 of frD. ps1 of frD is left UNCHANGED.

Another example (fdivs)
When HID2 PSE is low
1. Entire value of frA is divided by entire value of frB
2. Result placed in frB as 64-bit form but with single precision ofc
When HID2 PSE is high
1. ps0 of frA is divided by ps0 of frB
2. result placed into BOTH ps0 and ps1 of frD

Basically in all the single-float math-type instructions, when HID2 PSE is high, ps0 is input and ps0 + ps1 is output. As you can see above, the fmr instruction is an old ball with frD ps1 being unchanged. The frsp instruction is another odd ball to where the frD's ps1 is left undefined (junk).

The Broadway Manual has zero information about what occurs for frsqrte in regards to HID2 PSE. Nothing. So anyway I did some tests on Real Hardware and this is what occurs~

When HID2 PSE is low
1. Entire 64-bit frB used for input
2. frD gets result as 64-bits

When HID2 PSE is high
1. ps0 of frB is used for input
2. ps0 of frD gets result. ps1 of frD is left UNCHANGED


If anyone cares this is the following code I used for confirmation. f1 gets loaded as 4.0, 0.0. f2 gets loaded as 1.25, 1.25. I then perform a frsqrte (with HID2 PSE high) where f1 is frB and f2 is frD.

f2 resulted as 0x3EFFF400 3FA00000 (~0.499, 1.25). ps0 of f2 didn't result exactly as 0.5, this is expected due to the 1/4096 accuracy effect.

In conclusion this information is missing from the 1.0 version of the Broadway Manual which is the latest version afaik.

Code:
#C2 Address 807BA164
#Pick up box, see result on screen

.set HID2, 920
.set PSE, 0x2000

#Check PSE bit of HID2
mfspr r3, HID2
andis. r0, r3, PSE
bne+ good_to_go

#Set r5 arg for OSFatal
bl setbadfatal
.asciz "NOTE! PSE of HID2 is low. Try again or try a diff hook address."
setbadfatal:
mflr r5
b goodfatal

#Set our single float constant value (4)
good_to_go:
lis r3, 0x4080
ori r3, r3, 0x0000
li r4, 0
lis r5, 0x3FA0

#Place value into ps0 of f1 with ps1 being null
lis r31, 0x8000
ori r31, r31, 0x1500
stw r3, 0 (r31)
stw r4, 4 (r31)
stw r5, 8 (r31)
stw r5, 0xC (r31)
psq_l f1, 0 (r31), 0, 0
psq_l f2, 0x8 (r31), 0, 0

#Do square root on it
frsqrte f2, f1

#Store results
psq_st f2, 0x0 (r31), 0, 0

#Load the fpr into GPRs r5 and r6 for sprintf
lwz r5, 0 (r31)
lwz r6, 4 (r31)

#Set r4 arg for sprintf
bl setsprintf
.asciz "%08X %08X"
.align 2
setsprintf:
mflr r4

#Set r3 arg for sprintf
addi r3, r31, 0x40

#Clear cr1 eq bit cuz no floats for sprintf
crclr 6

#Call sprintf
lis r12, 0x8001
ori r12, r12, 0x1A2C
mtctr r12
bctrl

addi r5, r31, 0x40

#Setup OSFatal args
goodfatal:
bl setupfatal
.long 0xFFFFFFFF
.long 0
setupfatal:
mflr r3
addi r4, r3, 4

#Call OSFatal
lis r12, 0x801A
ori r12, r12, 0x4EC4
mtctr r12
bctr

Print this item

  Request: Additional sound trigger for Mushroom Gorge
Posted by: lschlick - 04-14-2024, 01:01 AM - Forum: Code Support / Help / Requests - Replies (6)

KCL flags of a given type can have up to 8 variants. In Mushroom Gorge, the KCL flag of type sound trigger has 4 defined variants, with the other 4 being having undefined behavior. The first defined variant enables annoying wind ambience. The other 3 defined variants enable cave ambience and reduce the music volume.

There are plenty of custom tracks that use Mushroom Gorge's property slot in which wind ambience does fit. Specifically those which are set in the skies or up on tall mountains. However, there are some custom tracks in which wind ambience does not fit. One such example is Mushoom Hideaway, which is set in more of a forested setting and not in the skies or up on tall mountains. For a track such as Mushroom Hideaway, there is no way to get the ambience sounding right for the given setting.

I could edit the brsar to set wind ambience volume to zero, but the problem is that it applies to every track, even the ones with a high-altitude setting in which wind ambience fits very well.

Most track slots have a sound trigger that allows you to disable all ambiences. But Mushroom Gorge has no such thing, yet it is in need of it. I am requesting a code that would interpret one of the unused sound trigger variants in Mushroom Gorge as a sound trigger that disables both wind ambience and cave ambience. Is this something that is hypothetically possible to make?

Print this item

  Fixing Blackscreen Everywhere on Debian 12 using NVidia 3080 12gb
Posted by: Vega - 04-09-2024, 03:18 PM - Forum: General Discussion - No Replies

I've bought a new setup (computer, monitor, etc) from my brother yesterday. A huge upgrade from my 7 year old Desktop, lmao.

Tried installing Debian 12. Install went great, but I was getting Blackscreen everywhere immediately after the GRUB bootloader echoed some basic outputs (right before the graphics are initiated).

So as a personal note for future reference and the off chance somebody needs this.. here's how to fix it!

The issue:
Blackscreen or Very Dark Gray Screen (may flicker) after GRUB screen. Using CTRL+ALT+F2 (to switch to TTY mode) does *NOT* work (still Blackscreens)

The solution:
1. Power off. Then power on.
2. Once GRUB loads, press down on keyboard to stop it from auto-booting
3. Navigate down on keyboard to pre-select  "Advanced Options for..."  Do *NOT* press Enter. Just be hovered over it
4. Press e on your keyboard to bring up GRUB's built in editor for the Advanced Options
5. The config file to how Grub will boot Debian will be shown
6. Using the arrow keys, navigate until you see the following...
quiet
7. Change that text to now be this...
quiet nomodeset
8. Now press F10 to save and exit. This will apply the new config file for the next boot *ONLY*.
9. You should be at a screen where you can select to boot regular Debian 12 or Debian 12 in recovery mode.
10. Choose regular Debian 12
11. Debian 12 will boot but using BIOS graphics.
12. Log in as root and open a terminal, run the following commands
apt update
apt upgrade
apt install nvidia-detect
13. Once nvidia-detect has been installed, run it...
nvidia-detect
14. The program will output a list of package(s), that you will need to install. For me it was just nvidia-drivers. You may have more or different packages
15. Install all the packages that were listed!!!
16. Once all packages are installed, reboot your computer.
17. GRUB will be back to using the original/default config file and you should now see that the graphics are fixed once Debian 12 boots.

Print this item

  Maximum Player Collision
Posted by: MarioKartUltimate - 04-06-2024, 11:09 PM - Forum: Code Support / Help / Requests - No Replies

Is there a code that provides Max Collision. I mean a code where if you bump into someone, they are send flying off instantly.

Print this item

  Load State at Breakpoint (specific game event)
Posted by: seanmcnally - 03-25-2024, 01:08 AM - Forum: Coding & Hacking General Discussion - Replies (1)

This is the story of a cheat code I wanted to make, was unable to make, and the hack-y solution I came up with to get around it.

In 4P mode, I was looking for a way to jump back to the character selection screen after each race, that way in a tournament setting where the players change each race, you wouldn't need to quit to the main menu each time.  As you probably know, normal behavior is that after each race, you press "next race", and it goes to the cup selection screen assuming you want to play again with the same character/vehicle selections.

I started out by trying to figure out the instruction where that menu - the cup selection screen - is loaded after you press next race.  Using this list, I was able to find that the cup selection menu is referred to as 6E, so I went to work with some excruciating dynamic analysis, going frame by frame until I found something that was writing 6E.  Good news, I did!  8070ca50 contains stw r30, 0x0004 (r29), and r30 contains 6E after you press next race.  Furthermore, r9 = 17 when you're accessing the cup selection screen from a new match, and r9 = 5 when you're accessing it from the "Next Race" button.  So you'd think I could just write a code to use load instruction on r30 before that 6E is written, and put something like 6B (Character Select) instead, but that didn't work.  The byte gets written successfully, but the game still goes into the cup selection screen.

It was at this point that I realized, maybe I can do this without affecting game logic at all.  I'm going to be using Dolphin for the tournament anyway, so what if, instead of a cheat code, I just loaded a state when that 8070ca50, r9 == 5 breakpoint hit?  I could just use Python to watch dolphin.log, and send a hotkey to load a state that jumps to the character select screen.

So....



Here's a very silly solution to my problem:

This is adapted from my Logging Game Events to Text File post.

1) In Dolphin, go to  Options > Configuration > Interface > Enable Debugging UI.

Go to View, make sure Breakpoints, Log, and Log Configuration are checked. Then, in the Log Configuration tab, uncheck everything except "Master Log (MASTER)" and "Memory Interface & Memory Map (MI)".  At this point you should probably find Dolphin's log file (dolphin.log) and delete it, that way you're starting fresh (on Windows it is found at C:\Users\YourUserName\AppData\Roaming\Dolphin Emulator\Logs).

2) Add 8070ca50 as a breakpoint for NTSC-U.  In the condition box, write r9 == 5.

These are the breakpoints for other versions (untested)
  • NTSC-U  8070ca50
  • PAL 0x807144f4
  • NTSC-J 0x80713b60
  • NTSC-K 0x8070289c

3) Save a state.  In my example, I'm using State Slot 1, default hotkey is Shift+F1 to save, F1 to load.

4) Run this Python script.  You'll need to install the keyboard module (run cmd as admin, pip install keyboard):

load-state-after-bp.py
Code:
import time
import os
import keyboard

class LogFileWatcher:
    def __init__(self, log_file):
        self.log_file = log_file
        self.last_position = 0
        self.current_data = ""
        print("Watching log file:", log_file)

    def watch(self):
        try:
            while True:
                self.dump_changes()
                time.sleep(0.05)
        except KeyboardInterrupt:
            print("Watcher stopped.")

    def dump_changes(self):
        try:
            with open(self.log_file, 'r') as f:
                f.seek(self.last_position)
                new_data = f.read()
                if new_data:
                    if new_data.startswith('\r\n'):
                        new_data = new_data[2:]  # Remove the first two characters (CR LF)
                    elif new_data.startswith('\n'):
                        new_data = new_data[1:]  # Remove the first character (LF)
                    self.current_data = new_data
                    print("Changes detected:")
                    print(self.current_data)
                    if "1. Vars:  r9=5" in new_data:
                        print("True")
                        keyboard.press('f1')  # Press F1 key
                        time.sleep(0.1)  # Hold F1 for 100 milliseconds
                        keyboard.release('f1')  # Release F1 key
                    self.last_position = f.tell()
        except Exception as e:
            print("Error occurred:", str(e))

if __name__ == "__main__":
    log_file = "C:\\Users\\Sean\\AppData\\Roaming\\Dolphin Emulator\\Logs\\dolphin.log"
   
    watcher = LogFileWatcher(log_file)
    watcher.watch()


5) Be sure to edit the log_file variable near the bottom to use your computer's username instead of mine.

And that's it.  Again, not ideal, but it does work.  I'm also aware there's a Dolphin module for Python that avoids needing to use keypresses and can just load the state directly, feel free to have a go at that if you want.

Print this item

  Game Resets after "Next Race" [SeanMcNally]
Posted by: seanmcnally - 03-23-2024, 04:04 AM - Forum: Incomplete & Outdated Codes - Replies (2)

Not even sure if I can call myself the creator of this one, since it basically just rips the activator out of Diamond's Press Button to Reset to Title Screen and puts it at an insertion address that I found.  The cup selection screen can be accessed from a bunch of different ways.  If r9 = 5, that means the cup selection screen was accessed from pressing "Next Race" after a race.  If r9 = 17, the cup selection screen was accessed from the starting a new grand prix or versus race and selecting your character, vehicle, and drift options.  This code checks for the first scenario.  Not ported, but here it is, for NTSC-U Only:

C270CA50 00000006
93DD0004 2C090005
41820008 48000020
3D80809B 618CD508
806C0000 3D808060
618C4CD8 7D8803A6
4E800021 00000000

Source Code:

Code:
# Insertion Address: 8070ca50 for NTSC-U
#
stw r30, 0x0004 (r29) # Default instruction
cmpwi r9, 5          # If r9 = 5, this instruction is running after pressing "next race"
# Worth noting that if r9 = 17, this instruction is running after the character select screen
beq game_reset # If five, reset the game
b end_code # If not, end the code
# This part resets the game, Diamond wrote this code
game_reset:
lis r12, 0x809B
ori r12, r12, 0xD508
lwz r3, 0(r12)
lis r12, 0x8060
ori r12, r12, 0x4CD8
mtlr r12
blrl
end_code:

Credits: Diamond, for creating the part that resets the game.

Print this item