List of Certain Functions with Arguments Plus Descriptions - Printable Version +- Mario Kart Wii Gecko Codes, Cheats, & Hacks (https://mariokartwii.com) +-- Forum: Hacks/Modding (https://mariokartwii.com/forumdisplay.php?fid=14) +--- Forum: Coding & Hacking General Discussion (https://mariokartwii.com/forumdisplay.php?fid=23) +--- Thread: List of Certain Functions with Arguments Plus Descriptions (/showthread.php?tid=1117) |
List of Certain Functions with Arguments Plus Descriptions - Vega - 04-05-2019 List of Certain Functions with Arguments Plus Descriptions This is a list of functions I have used in codes I have made or attempted to have made. Arguments, descriptions, and return values are provided. If you are wanting to view a list of many many more functions (not as detailed as this), view this thread HERE. There's no need to have essentially two symbol map type threads in the Resources sub-forum, hence why this thread is in Hacking General sub-forum. ISFS Specific Return Values (r3) For any function that has the term ISFS in it, they all have the same return value numbering. Here's a list of those values (shown in decimal form): -1 = Permission Denied -2 = File/Directory already exists -4 = Invalid Register Argument -6 = File/Directory not found -8 = Resource busy -12 = ECC error -22 = Could not allocate Memory -101 = Invalid Register Argument -102 = Permission Denied -105 = File/Directory already exists -106 = File/Directory not found -107 = Too many fds open -108 = Memory is full -109 = Too many fds open -110 = Pathname is too long -111 = fd already open -114 = ECC error -115 = Directory not empty -116 = Max directory depth exceeded -118 = Resource busy -119 = Fatal error Function: memcpy Summary: Copies Data from a spot in Memory to another spot; useful for very large amounts of data Address (region-free): 0x80005F34 Arguments: r3 = Destination Start Address r4 = Source Start Address r5 = Amount of Bytes to Copy Over Return Value: r3 = Remains the same ~~~ Function: sprintf Summary: Formats a String (C/C++ style) and stores string to desired memory location Addresses: NTSC-U 0x80010ECC PAL = 0x80011A2C NTSC-J = 0x80011950 NTSC-K = 0x80011A94 Arguments: r3 = Address Pointer where Formatted String ASCii-Hex will be written to r4 = Address Pointer where non-formatted ASCii-Hex String is located, must end in NULL r5 thru r10 = Non-Float Values to be formatted f1 thru f8 = Float Values to be formatted NOTE: You must use single precision (lfs instruction) if loading floats from memory into FPRs More NOTES: If using Float Values ,then this instruction must be required after the lfs (before the function call) - crset 6 (same as creqv 6, 6, 6) If NOT using Float values, its recommended (not needed) to use this instruction right before the function call - crclr 6 (same as crxor 6, 6, 6); This tells the sprintf function not to backup Floats to the stack since no Floats are used. Here is a handy page for printf formats - https://alvinalexander.com/programming/printf-format-cheat-sheet/ Return Value (r3): Value matching amount of bytes written to r3 (does not include the auto appended null byte at end) = Success Any negative value = Error ~~~ Function: sscanf Summary: Reads data from a Formatted C/C++ String. Addresses: NTSC-U too lazy to port lol PAL = 0x80013040 NTSC-J = too lazy to port lol NTSC-K = too lazy to port lol Arguments: r3 = Address Pointer where Formatted String ASCii-Hex is located at, must end in NULL r4 = Address Pointer where non-formatted ASCii-Hex String is located, must end in NULL r5 thru r10 varies depending on how many formatted values you need to read from the Formatted String (i.e. % items) r5 thru r10 are pointer to where the dump the read data Example: r3 = Pointer to memory where the following string is at - "Bob is 25 years old" For reading the "25" part of the string, set r4 pointer to point to this string "Bob is %d years old" r5 will then need to be a pointer to dump the "25" to. %d is used because 25 is in decimal form. Let's say r5 is 0x80001500. After sscanf is called, at 0x80001500 will be the word value 0x00000019 (25 in decimal). Haven't personally tested, but float values (i.e. %3.1f) should not use pointers. They should get placed directly into the FPRs, starting at f1. NOTE: You must use single precision (lfs instruction) if loading floats from memory into FPRs More NOTES: If using Float Values ,then this instruction must be required after the lfs (before the function call) - crset 6 (same as creqv 6, 6, 6) If NOT using Float values, its recommended (not needed) to use this instruction right before the function call - crclr 6 (same as crxor 6, 6, 6); This tells the sprintf function not to backup Floats to the stack since no Floats are used. Here is a handy page for printf formats - https://alvinalexander.com/programming/printf-format-cheat-sheet/ Return Value (r3): Items of Data that were successfully read = r3 If r3 = 0, no reading/conversions were done. If r3 is a negative value then r3 or r4 args were incorrect. ~~~ Function: swprintf Summary: Formats a String (C/C++ style) using 16-bit ASCII (instead of 8 bit) and stores string to desired memory location Addresses: NTSC-U 0x80016CB4 PAL = 0x80017814 NTSC-J = 0x80017738 NTSC-K = 0x8001787C Arguments: r3 = Address Pointer where wide Formatted String will be written to r4 = Number of characters to fill in the formatted string that will be written to r3's address, note its pretty hard to calculate this, thus you can just put this as a crazy high number because the function itself will autocap to the max of the formatted string. Thank you Seeky! r5 = Address Pointer where non-formatted String is located, must end in NULL r6 thru r10 = Integer Values to be formatted f1 thru f8 = Float Values to be formatted NOTE: You must use single precision (lfs instruction) if loading floats from memory into FPRs More NOTES: If using Float Values ,then this instruction must be required after the lfs (before the function call) - crset 6 (same as creqv 6, 6, 6) If NOT using Float values, its recommended (not needed) to use this instruction right before the function call - crclr 6 (same as crxor 6, 6, 6); This tells the swprintf function not to backup Floats to the stack since no Floats are used. Here is a handy page for printf formats - https://alvinalexander.com/programming/printf-format-cheat-sheet/ Return Value (r3): Positive Value = Success; amount of halfwords written -1 = Error; r4's value was too low. Formatted string will still be there but the function is letting you know its incomplete ~~~ Function: DirectPrint: SetupFB Summary: Sets up a Frame Buffer to allow later use of DirectPrint: Printf & DirectPrint: StoreCache Addresses: NTSC-U 0x800223E0 PAL 0x80022480 NTSC-J 0x800223A0 NTSC-K 0x800224E0 Arguments: For r3, 2 instructions must bed used to get the Render Mode of mpVideo from RKSystem, the first instruction slightly differ per region: NTSC-U = lwz r3, -0x5CA8 (r13) PAL = lwz r3, -0x5CA0 (r13) NTSC-J = lwz r3, -0x5CA0 (r13) NTSC-K = lwz r3, -0x5C80 (r13) Then execute the 2nd instruction (region-free): lwz r3, 0x0 (r3) r3 now contains the RenderMode Return Value (r3): Any negative value = Error ~~~ Function: DirectPrint: Printf w/ DirectPrint: StoreCache Summary: Both functions should be executed back-to-back hence why they are coupled together. These functions will preform a printf-style function that draws on the TV Screen; DirectPrint: SetupFB must already have been called beforehand Addresses (Printf first, StoreCache second) NTSC-U = 0x80021DF0, 0x80021DD0 PAL = 0x80021E90, 0x80021E70 NTSC-J = 0x80021DB0, 0x80021D90 NTSC-K = 0x80021EF0, 0x80021ED0 Arguments (for Printf only, StoreCache has no arguments): r3 = X Coordinate (Starts Far Left) r4 = Y Coordinate (Starts Very Top) r5 = 0 for No Text Wrap, 1 for Text Wrap (Wrapping allows the text to enter into a new line if it reaches the edge of the screen) r6 = Address Pointer to ASCii-Hex String that will be Drawn on Screen r7 thru r10 = Standard printf format non-float arguments f1 thru f13 = Standard printf format float arguments NOTE: You must use single precision (lfs instruction) if loading floats from memory into FPRs Another NOTE: If using Float Values ,then this instruction must be required after the lfs (before the function call) - crset 4*cr1+eq Google printf Format for a list of format characters/symbols for use in the ASCii-Hex String. Return Value (r3): Any negative value = Error ~~~ Function: ISFS_CreateDir Summary: Creates a new directory on the NAND Addresses: NTSC-U = 80169DD4 PAL = 0x80169E74 NTSC-J = 0x80169D94 NTSC-K = 0x80169F10 Arguments: r3 = Address that points to the File Path w/ new Directory that will be created r4 = 0x0 (u8 attributes) r5 = 0x3 (owner permissions) r6 = 0x3 (group permissions) r7 - 0x3 (other permissions) Return Value (r3): 0 = Success View ISFS List at top for negative values ##SPECIAL NOTE ABOUT ISFS_CreateDir & DOLPHIN## Return value -105 will never occur on Dolphin for a Directory that already exists. It will instead return 0. ~~~ Function: ISFS_Delete Summary: Delete a file or directory (recursively) from the NAND. Addresses: NTSC-U = 0x8016A6EC PAL = 0x8016A78C NTSC-J = 0x8016A6AC NTSC-K = 0x8016A828 Arguments: r3 = Address that points to file path Return Value (r3): 0 = Success View ISFS List at top for negative values ~~~ Function: ISFS_CreateFile Summary: Creates a new file on the NAND, must use a pre-existing directory Addresses: NTSC-U = 0x8016ABD4 PAL = 0x8016AC74 NTSC-J = 0x8016AB94 NTSC-K = 0x8016AD10 Arguments: r3 = Address that points to the File Path w/ new File that will be created r4 = 0x0 (u8 attributes) r5 = 0x3 (owner permissions) r6 = 0x3 (group permissions) r7 = 0x3 (other permissions) Return Value (r3): 0 = Success View ISFS List at top for negative values ~~~ Function: ISFS_Open Summary: Opens a pre-existing file on the NAND to allow you to later read from it or write to it Addresses: NTSC-U = 0x8016ADBC PAL = 0x8016AE5C NTSC-J = 0x8016AD7C NTSC-K = 0x8016AEF8 Arguments: r3 = Address that points to the File Path r4 = Permissions (Use 0x1 for Read, or 0x2 for Write) Return Values (r3): Success = File Descriptor Value Returned View ISFS List at top for negative values ~~~ Function: ISFS_GetFileStats Summary: Gets the file's size (in bytes). Can be useful before calling ISFS_Read if the file size is unknown. Addresses: NTSC-U = 0x8016AF3C PAL = 0x8016AFDC NTSC-J = 0x8016AEFC NTSC-K = 0x8016B078 Arguments: r3 = File Descriptor (value that was returned from ISFS_Open) r4 = Memory Address to dump file size value (word) to. Address must be 32 byte aligned aka is address divisible by 0x20?) Return Value (r3): 0 = Success View ISFS List at top for negative values ~~~ Function: ISFS_Seek Summary: Only recommended for reading/writing in a particular region of a very large file when not reading/writing at the very beginning of said file. Use after Open, before Read/Write. Addresses: NTSC-U = 0x8016B0CC PAL = 0x8016B16C NTSC-J = 0x8016B08C NTSC-K = 0x8016B208 Arguments: r3 = File Descriptor (value that was returned from ISFS_Open) r4 = Offset from Location Mode aka where r5 = Location Mode aka whence; 0x0 for Start of File, 0x1 = Current Spot of File, 0x2 = End of File Return Value (r3): 0 = Success View ISFS List at top for negative values ~~~ Function: ISFS_Read Summary: Read a file on the NAND to dump it's contents to a spot in Memory Addresses: NTSC-U = 0x8016B15C PAL = 0x8016B1FC NTSC-J = 0x8016B11C NTSC-K = 0x8016B298 Arguments: r3 = File Descriptor (value that was returned from ISFS_Open) r4 = Address that points where the File's data will be dumped to (must be 32 byte aligned aka is address divisible by 0x20?) r5 = Amount of Bytes of Data to dump from the File Return Value (r3): If r3 value's equals r5, then Success. View ISFS List at top for negative values ~~~ Function: ISFS_Write Summary: Write to a file on the NAND. Addresses: NTSC-U = 0x8016B220 PAL = 0x8016B2C0 NTSC-J = 0x8016B1E0 NTSC-K = 0x8016B35C Arguments: r3 = File Descriptor (value that was returned from ISFSOpen) r4 = Address that points to the string of data that will be used to write to the File (must be 32 byte aligned aka is address divisible by 0x20?) r5 = Amount of Bytes of Data to write from the string Return Value (r3): If r3 value's equals r5, then Success. View ISFS List at top for negative values ~~~ Function: ISFS_Close Summary: Close a file after reading from it or writing to it. This function must be done after the read/write. Addresses: NTSC-U = 0x8016B2E4 PAL = 0x8016B384 NTSC-J = 0x8016B2A4 NTSC-K = 0x8016B420 Arguments: r3 = File Descriptor (value that was returned from ISFS_Open) Return Value (r3): 0 = Success View ISFS List at top for negative values ~~~ Function: OSFatal Summary: Stops the game and displays a desired message on the TV screen. BG color, FG color, and text are all modifiable. Addresses: NTSC-U = 0x801A4E24 PAL = 0x801A4EC4 NTSC-J = 0x801A4DE4 NTSC-K = 0x801A5220 Arguments: r3 = Address Pointer to Foreground (text) color r4 = Address Pointer to Background color r5 = Address Pointer to String of ASCII Text Extra Notes: Color = RRGGBBFF RR = Red Value, GG = Green Value, BB = Blue Value Return Value (r3): None ofc... ~~~ Function: OSShutdownSystem Summary: Standard shutdown of the Wii. Addresses: NTSC-U = 0x801A84CC PAL = 0x801A856C NTSC-J = 0x801A848C NTSC-K = 0x801A88C8 Arguments: None Return Value (r3): None ofc... ~~~ Function: OSRestart Summary: Reboots the game. Addresses: NTSC-U = 0x801A85E8 PAL = 0x801A8688 NTSC-J = 0x801A85A8 NTSC-K = 0x801A89E4 Arguments: None Return Value (r3): None ofc... ~~~ Function: OSReturnToMenu Summary: Returns you to the Wii Menu. Addresses: NTSC-U = 0x801A87B8 PAL = 0x801A8858 NTSC-J = 0x801A8778 NTSC-K = 0x801A8BB4 Arguments: None Return Value (r3): None ofc... ~~~ Function: OSGetTime Summary: Returns a 64 bit Time value base, that you can use later with the function OSTicksToCalendarTime to grab the data&time from the Wii's CPU. Addresses: NTSC-U = 0x801AACBC PAL = 0x801AAD5C NTSC-J = 0x801AAC7C NTSC-K = 0x801AB0B8 Arguments: None Return Values (r3, r4): r3 = Upper 32 bits of Time Base r4 = Lower 32 bits of Time Base ~~~ Function: OSTicksToCalendarTime Summary: After you have executed the OSGetTime function, immediately execute this function to get the date&time. Arguments: r3 = Upper Time Base r4 = Lower Time Base r5 = Memory Address to Dump Date/Time to (have at least 0x28 space allocated to dump to) Dumping Locations (all dumped as logical words): r5 = Seconds r5+4 = Minutes r5+8 = Hours r5+C = Day of Month r5+10 = Month (read notes below) r5+14 = Year (read notes below) r5+18 = Day of Week (read notes below) r5+1C = Day of Year (read notes below) r5+20 = Milliseconds r5+24 = Microseconds Notes: For the month, January starts off as 0. For day of week, Sunday starts off as 0. For day of year, Jan 1st starts off as 0. For the year, if you want just the last two digits (2019/0x7E3 -> 19/0x13) use this equation.. Assume Year is placed into r5... li r6, 100 divw r7, r5, r6 mullw r6, r7, r6 subf r5, r6, r5 r5 now equals last two digits of Year Return value (r3): If any negative number, then error. ~~~ Function: _OSShutdownToSBY Summary: Shuts down the Wii to 'Red' light mode (completely off) even if your Wii is configured to shut down to 'Yellow' light mode Addresses: NTSC-U = 0x801AB8C0 PAL = 0x801AB960 NTSC-J = 0x801AB880 NTSC-K = 0x801ABCBC Arguments: None Return Value (r3): None ofc... ~~~ Function: _OSHotReset Summary: Reboots the Wii Addresses: NTSC-U = 0x801AB938 PAL = 0x801AB9D8 NTSC-J = 0x801AB8F8 NTSC-K = 0x801ABD34 Arguments: None Return Value (r3): None ofc... ~~~ Function: _OSLaunchTitle Summary: Launches desired Wii Channel NOTE: It CAN load the Homebrew Channel, but CANNOT load the Region Select Channel. Addresses: NTSC-U = 0x801AD960 PAL = 0x801ADA00 NTSC-J = 0x801AD920 NTSC-K = 0x801ADD5C Arguments: r3 = Upper 32 Bits of Title ID (ASCii-Hex) r4 = Lower 32 Bits of Title ID Return Value (r3): None ofc... ~~~ Function: OSLaunchTitleI Summary: Launches desired Wii Channel NOTE: Cannot load Homebrew Channel Addresses: NTSC-U = 0x801ADEC0 PAL = 0x801ADF60 NTSC-J = 0x801ADE80 NTSC-K = 0x801AE2BC Arguments: r3 = Upper 32 Bits of Title ID (ASCii-Hex) r4 = Lower 32 Bits of Title ID r5 = 0x03010000 r6 = 0 Return Value (r3): None ofc... ~~~ Function: SCGetSimpleAddr Summary: This will dump your Country Code, Region Residence Code, and Globe location from SYSCONF to a desired address. You will need at least 0x1008 blocks/bytes of free space. Addresses: NTSC-U = 0x801B1FD4 PAL = 0x801B2074 NTSC-J = 0x801B1F94 NTSC-K = 0x801B23D0 Arguments: r3 = Address Where Country Code byte will be stored to (must be 32 bit aligned) r3 + 0x1 = Address Where Region Residence byte will be stored to r3 + 0x1004 = Address Where Globe Location word will be stored to Return Value (r3): If r3 = 1, then success. If not, then unable to get Simple Address Data from SYSCONF. ~~~ Function: SCGetProductArea Summary. This will dump your Console Area (3 Byte Capitalized ASCII) to a speicific address in Memory. Addresses: NTSC-U = 0x801B2300 PAL = 0x801B23A0 NTSC-J = 0x801B22C0 NTSC-K = 0x801B26FC Arguments: r3 = Address to Dump Console Area too Return Value (r3): If r3 = 1, then success. If not, then unable to get Product Area from setting.txt. ~~~ Function: SCGetProductCode Summary: This will dump the product code at a specific address in Static Memory. Once the product code is dumped, it will stay there until the Game is turned off Addresses: NTSC-U = 0x801B2384 PAL = 0x801B2424 NTSC-J = 0x801B2344 NTSC-K = 0x801B2780 Arguments: None Return Value (r3): If r3 = 1, then success. If not, then unable to get Product Code from setting.txt. ~~~ Function: SCGetProductSN Summary: This will dump the Serial Number at a specific address in Dynamic Memory. It will only be there during the DWC process of connecting to Wifi, then it will be cleared. Addresses: NTSC-U = 0x801B23C0 PAL = 0x801B2460 NTSC-J = 0x801B2380 NTSC-K = 0x801B27BC Arguments: None Return Value (r3): If r3 = 1, then success. If not, then unable to get SN from setting.txt. ~~~ Function: NCDiGetWirelessMacAddress Summary: This will dump your MAC Address at a speicific address in Dynamic Memory. It will only be there during the DWC process of connecting to Wifi, then it will be cleared. However, you can change the first argument (r3) to dump it to a different spot if needed and not have it cleared. Addresses: NTSC-U = 0x801D0CD0 PAL = 0x801D0D70 NTSC-J = 0x801D0C90 NTSC-K = 0x801D10CC Arguments: r3 = Address to dump MAC to Return Value (r3): If r3 = 0, then success. If not, then error attempting to get MAC from dev/fs. ~~~ Function: NETCalcCRC32 Summary: Calculates a CRC32-bit checksum. This function is required if you are wanting to make a code to modify MKWii's data save file (rksys.dat) Addresses: NTSC-U = 0x801D1C00 PAL = 0x801D1CA0 NTSC-J = 0x801D1BC0 NTSC-K = 0x801D1FFC Arguments (r3, r4): r3 = Address Pointer to start of Contents in Memory to be used for the CRC32 Calculation r4 = Amount of Bytes to be used for the CRC32 Calculation Return Value (r3): r3 = CRC32-bit checksum calculated from contents (word) ~~~ Function: EGG::Heap::alloc Summary: Creates a block of empty memory for available use. Addresses: NTSC-U = 0x80229490 PAL = 0x80229814 NTSC-J = 0x80229734 NTSC-K = 0x80229B88 Arguments (r3, r4, r5): r3 = Size of Memory Block in Bytes r4 = Alignment of Memory Block (if not sure, use 0x20 for 32 bit alignment) For r5, 2 instructions must be preformed. The first instruction (get pointer from System Heap) will vary per region... NTSC-U = lwz r5, -0x5CA8 (r13) PAL = lwz r5, -0x5CA0 (r13) NTSC-J = lwz r5, -0x5CA0 (r13) NTSC-K = lwz r5, -0x5C80 (r13) Second instruction for r5: lwz r5, 0x0024 (r5) r5 thus has the Heap to allocate memory block in Return Value (r3): r3 = Pointer to Beginning of new Heap to use ~~~ Function: EGG::Heap::free Summary: Free the block of memory that was created from EGG::Heap::alloc Addresses (r3, r4): NTSC-U = 0x80229800 PAL = 0x80229B84 NTSC-J = 0x80229AA4 NTSC-K = 0x80229EF8 Arguments: r3 = Return value from EGG::Heap::alloc (Pointer to Beginning of Heap) For r4, 2 instructions must be preformed. The first instruction (get pointer from System Heap) will vary per region... NTSC-U = lwz r4, -0x5CA8 (r13) PAL = lwz r4, -0x5CA0 (r13) NTSC-J = lwz r4, -0x5CA0 (r13) NTSC-K = lwz r4, -0x5C80 (r13) Second instruction for r4: lwz r4, 0x24 (r4) Return Value (r3): If r3 = 1, then Success. Heap is freed. If not, then some sort of error occured. ~~~ Credits: Megazig RiiDefi Bushing Star |