Skip to content

A GCI gecko code loader for everyone's favorite game: Super Mario Sunshine

License

Notifications You must be signed in to change notification settings

BitPatty/sms-gci-gecko-loader

 
 

Repository files navigation

SMS GCI Loader

A modification of Super Mario Sunshine that allows to read additional codes from the memory card.

This is used within the GCT Generator project for allowing codes exceeding certain thresholds to be loaded from a patched memory card (a memory card that has the codes loaded as a GCI).

Project structure

  • gecko directory contains the logic for creating the loader's gecko code
  • include contains the header files
  • source directory contains the loader code itself that is used to read the GCI file from the memory card.

How it works

The loader code uses the system and game APIs to read data from the memory card. The main.c contains a hook onReadOptionsBlock that intercepts the initial memory card read from the game itself. It then first loads the codes from the memory card into memory and then the actual game file that the game tries to access.

  1. The gecko code handler writes the Gecko codes as usual, the call to open the memory card from the game is overriden with a jump our code
  2. Early after startup the game wants reads the memory card and ends up in the onReadOptionBlock function
  3. The game jumps to our custom code
  4. The cheat codes are loaded form the memory card into memory starting from 0x817F8008
  5. The memory card is opened (restore of the overriden call)
  6. The process is marked as DONE (2)
  7. The gosub is called which, 7.1 backs up the link register in GCTDST.returnAddr 7.2 sets the link register to the GCTDST.code and blr's to it
  8. The code handler continues
  9. The code handler blr's to address stored in GCTDST.returnAddr

Note: For the last step to work the GCT is expected to end with the following instruction set:

lis r3, 0x817F
lwzu r15, 0x17fc(r3)  ; GMDST
sub r15, r4, r15      ; r15 = current instruction - r15
blr

or in Gecko:

C0000000 00000002
3C60817F 81E317FC
7DE47850 4E800020

Sample gecko code produced

Note: The gosub MUST be right after the loader code

077FD800 0000058A  # Gecko
9421FFE8 7C0802A6  # `main` binary
93C10010 7C9E2378
38800001 93810008
93A1000C 7C7C1B78
93E10014 7CDD3378
9001001C 7CBF2B78
4AAB50E5 2C030000
408200AC 807C0000
7FE4FB78 7FC5F378
4AB5BB45 7C7F1B79
40820064 3D20817F
6129E800 7D3D4850
2809BFFF 40810088
38A00000 7FA4EB78
60A5C000 38C00000
7FC3F378 4AB5C4A5
7C7F1B79 40820070
7FC3F378 4AB5BC79
8001001C 7FE3FB78
83810008 83A1000C
7C0803A6 83C10010
83E10014 38210018
4E800020 2C1FFFFC
41A2FFD8 8001001C
3BE0FFFE 7FE3FB78
83810008 83A1000C
7C0803A6 83C10010
83E10014 38210018
4E800020 3BE0FFFF
4BFFFFA8 3BE0FFFD
4BFFFFA0 3BE0FFFB
4BFFFF98 9421FF08
7C0802A6 93C100F0
7C9E2378 93E100F4
7C7F1B78 900100FC
90A10088 90C1008C
90E10090 91010094
91210098 9141009C
40860024 D82100A0
D84100A8 D86100B0
D88100B8 D8A100C0
D8C100C8 D8E100D0
D90100D8 3D208041
80DF0004 8089E188
38E00002 38A00000
39410100 39210080
98E10070 98A10071
38610008 391F000C
38FF0008 38A00000
91410074 91210078
4AAD0369 A95F0000
3D004330 A93F0002
3CC08180 6D478000
910100E0 6D298000
90E100E4 912100EC
3CE08180 910100E8
7FC5F378 C006DC9C
38610008 C96100E8
38C10070 C98100E0
388000FF 813F0004
FD8C0028 91410024
FC0B0028 C167DCA0
91210064 FD806018
91210060 FC000018
D1610034 D181002C
D0010030 4AAD01B1
800100FC 83C100F0
83E100F4 7C0803A6
382100F8 4E800020
9421FFF0 3CA08180
7C0802A6 39200001
93E1000C 3FE0817F
38DF17F8 38A5DCFC
38C60008 90010014
913F17F8 4BFFFDAD
2C030000 40820008
38600002 80010014
907F17F8 7C0803A6
83E1000C 38210010
4E800020 9421FFE8
93A1000C 3FA0817F
813D17F8 93C10010
7C9E2378 2C090000
93E10014 7C7F1B78
40810020 83A1000C
7FC4F378 7FE3FB78
83C10010 83E10014
38210018 4AAB4614
38DD17F8 3CA08180
7C0802A6 39200001
38C60008 38A5DCFC
9001001C 913D17F8
4BFFFD21 2C030000
4182002C 8001001C
907D17F8 7C0803A6
83A1000C 7FC4F378
7FE3FB78 83C10010
83E10014 38210018
4AAB45C0 8001001C
38600002 907D17F8
7C0803A6 4BFFFFD4
9421FFE8 7C0802A6
9001001C 4AACC6AD
3D20803F 89299708
28090003 40810070
3D20817F 3D408180
80A917F8 392ADC8C
80CADC8C 39450005
80E90004 280A0007
81090008 8129000C
90C10008 90E1000C
91010010 91210014
41810020 3D208180
554A103A 3929DC6C
7D49502E 7D2A4A14
7D2903A6 4E800420
3C808180 38610008
3884DD74 4CC63182
4BFFFD4D 8001001C
38210018 7C0803A6
4E800020 3C808180
38610008 3884DD60
4CC63182 4BFFFD29
4BFFFFDC 3C808180
38610008 3884DD28
4CC63182 4BFFFD11
4BFFFFC4 3C808180
38610008 3884DD08
4CC63182 4BFFFCF9
4BFFFFAC 3C808180
38610008 3884DCE8
4CC63182 4BFFFCE1
4BFFFF94 3C808180
38610008 3884DCC4
4CC63182 4BFFFCC9
4BFFFF7C 3C808180
38610008 3884DCA8
4CC63182 4BFFFCB1
4BFFFF64 3C808180
38610008 3884DD40
4CC63182 4BFFFC99
4BFFFF4C FFFFFF70
FFFFFF88 FFFFFFA0
FFFFFFB8 FFFFFFD0
FFFFFFE8 FFFFFF58
FFFFFF48 001001B8
00000020 FF3333BB
FF3333BB 59800004
00000000 00000000
4661696C 20746F20
6D6F756E 74206D65
6D6F7279 20636172
64000000 4661696C
20746F20 6F70656E
20474349 2066696C
653A2047 43545F47
4D534530 31000000
47434920 66696C65
20746F6F 206C6172
67653A20 4743545F
474D5345 30310000
47434920 66696C65
206E6F74 20657869
7374733A 20474354
5F474D53 45303100
4661696C 20746F20
72656164 20474349
2066696C 65000000
50726570 6172696E
6720746F 206C6F61
64204743 49206669
6C652E2E 2E000000
4C6F6164 696E6720
47434920 66696C65
2E2E2E00 556E6B6E
6F776E20 47434920
4572726F 723A2025
64000000 00000000 # End of `main` binary + padding
042B17D0 4954C2AD # onReadOptionBlock hook
042A62B0 49557879 # willDrawFader hook
C0000000 00000005 # gosub
3C60817F 840317F8
2C000002 4C820020
7C0F2214 90030004
39E30008 7DE47850
4E800020 4E800020 # end of gosub

About

A GCI gecko code loader for everyone's favorite game: Super Mario Sunshine

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 40.3%
  • Python 32.7%
  • Makefile 21.7%
  • Assembly 2.9%
  • Dockerfile 1.3%
  • Shell 1.1%