├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── exploit ├── Makefile ├── ac.c ├── gaej_v100.ld ├── gaej_v101.ld ├── gafe.ld ├── gafj_v100.ld ├── gafj_v101.ld ├── gafp_eng.ld ├── gafp_fre.ld ├── gafp_ger.ld ├── gafp_ita.ld ├── gafp_spa.ld ├── gafu.ld ├── nesrom │ ├── README.md │ ├── ldscripts │ │ └── nes.ld │ ├── resources │ │ ├── chr.chr │ │ ├── nametable.nam │ │ ├── nametable2.nam │ │ └── pal.pal │ ├── src │ │ ├── cool_macros.asm │ │ ├── header.asm │ │ ├── main.asm │ │ ├── nes.asm │ │ └── utils.asm │ └── tools │ │ ├── ACNESCreator.CommandLine.exe │ │ ├── ACNESCreator.Core.dll │ │ ├── GCNToolKit.dll │ │ ├── README.md │ │ ├── ca65 │ │ ├── ca65.exe │ │ ├── ld65 │ │ └── ld65.exe └── start.S ├── patcher ├── Makefile ├── gaej_v100.ld ├── gaej_v101.ld ├── gafe.ld ├── gafj_v100.ld ├── gafj_v101.ld ├── gafp_eng.ld ├── gafp_fre.ld ├── gafp_ger.ld ├── gafp_ita.ld ├── gafp_spa.ld ├── gafu.ld └── start.S └── town ├── README.md ├── gaej.gci ├── gafe.gci ├── gafj.gci ├── gafp.gci ├── gafu.gci └── unedited ├── gaej.gci ├── gafe.gci ├── gafj.gci ├── gafp.gci └── gafu.gci /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "loader"] 2 | path = loader 3 | url = https://github.com/FIX94/gc-exploit-common-loader.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 FIX94 2 | # This code is licensed to you under the terms of the GNU GPL, version 2; 3 | # see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 4 | 5 | all: 6 | @$(MAKE) --no-print-directory -C loader 7 | @mv -f loader/loader.h exploit/loader.h 8 | @$(MAKE) --no-print-directory -C patcher 9 | @mv -f patcher/*.pat exploit 10 | @$(MAKE) --no-print-directory -C exploit 11 | @mkdir -p gci 12 | @mv -f exploit/*.gci gci 13 | 14 | clean: 15 | @$(MAKE) --no-print-directory -C patcher clean 16 | @$(MAKE) --no-print-directory -C loader clean 17 | @$(MAKE) --no-print-directory -C exploit clean 18 | rm -rf gci 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ac-exploit-gc 2 | An exploit for all the gamecube versions of animal crossing, you only need a method of injecting the two needed exploit .gci files you can download from the "Releases" tab above, also make sure to read the notes of the release for more information. 3 | This exploit will load a homebrew boot.dol converted to a .gci with dol2gci (included in Home Bros.) from your memory card, you can also find ready-to-use homebrew .gci executables in both gameboy interface and swiss-gc. 4 | Probably the easiest way to install those .gci files is using a wii that already has homebrew on it and the memory card manager GCMM, just put the .gci files on a folder called "MCBACKUP" on your sd card and then use GCMM. 5 | To trigger the exploit, load up the town, go into the house, click on the nes and start "LoadDOL", exit the nes with l+r+z and then just wait for the dol to load up automatically about 20 seconds after exiting the nes. 6 | 7 | This exploit was made possible thanks to: 8 | The original find by jamchamb, read up on how he did it if you are interested: 9 | https://jamchamb.github.io/2018/07/11/animal-crossing-nes-emulator-hacks.html 10 | The great work by Cuyler36 for writing both ACSE: 11 | https://github.com/Cuyler36/ACSE 12 | and the original ACNESCreator: 13 | https://github.com/Cuyler36/ACNESCreator 14 | Though this does not use that original version, I just made some small changes to make it easier to work for all the versions I have to compile: 15 | https://github.com/FIX94/ACNESCreator 16 | -------------------------------------------------------------------------------- /exploit/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 FIX94 2 | # This code is licensed to you under the terms of the GNU GPL, version 2; 3 | # see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 4 | 5 | 6 | # Configuration: 7 | 8 | # What toolchain prefix should we use 9 | CROSS ?= powerpc-eabi- 10 | 11 | ifeq ($(OS),Windows_NT) 12 | MKNES = $(CURDIR)/nesrom/tools/ACNESCreator.CommandLine.exe 13 | CA65 = $(CURDIR)/nesrom/tools/ca65.exe 14 | LD65 = $(CURDIR)/nesrom/tools/ld65.exe 15 | else 16 | MKNES = $(CURDIR)/nesrom/tools/ACNESCreator.CommandLine 17 | CA65 = $(CURDIR)/nesrom/tools/ca65 18 | LD65 = $(CURDIR)/nesrom/tools/ld65 19 | endif 20 | 21 | # End of configuration. 22 | 23 | 24 | 25 | # Set CC, LD, OBJCOPY based on CROSS, unless they are set already 26 | 27 | ifeq ($(origin CC), default) 28 | CC := $(CROSS)gcc -m32 29 | endif 30 | ifeq ($(origin LD), default) 31 | LD := $(CROSS)ld 32 | endif 33 | OBJCOPY ?= $(CROSS)objcopy 34 | 35 | 36 | # The compiler flags we need. 37 | 38 | CFLAGS := -Wall -W -O1 -ffreestanding -mno-eabi -mno-sdata -mcpu=750 39 | 40 | 41 | # Build with "V=1" to see the commands executed; be quiet otherwise. 42 | 43 | ifeq ($(V),1) 44 | Q := 45 | else 46 | Q := @ 47 | MAKEFLAGS += --no-print-directory 48 | endif 49 | 50 | 51 | targets := gaej_v100.gci gaej_v101.gci gafe.gci gafj_v100.gci gafj_v101.gci gafp_eng.gci gafp_ger.gci gafp_fre.gci gafp_spa.gci gafp_ita.gci gafu.gci 52 | 53 | objs := ac.o start.o 54 | 55 | all: $(targets) 56 | 57 | gaej_v100.gci: REGION := J 58 | gaej_v100.gci: IS_DNME := 1 59 | gaej_v100.gci: PATCH_PTR := 80291244 60 | 61 | gaej_v101.gci: REGION := J 62 | gaej_v101.gci: IS_DNME := 1 63 | gaej_v101.gci: PATCH_PTR := 80291EBC 64 | 65 | gafe.gci: REGION := E 66 | gafe.gci: IS_DNME := 0 67 | gafe.gci: PATCH_PTR := 802181E0 68 | 69 | gafj_v100.gci: REGION := J 70 | gafj_v100.gci: IS_DNME := 0 71 | gafj_v100.gci: PATCH_PTR := 80217568 72 | 73 | gafj_v101.gci: REGION := J 74 | gafj_v101.gci: IS_DNME := 0 75 | gafj_v101.gci: PATCH_PTR := 80217AA8 76 | 77 | gafp_eng.gci: REGION := P 78 | gafp_eng.gci: IS_DNME := 0 79 | gafp_eng.gci: PATCH_PTR := 8022BE54 80 | 81 | gafp_ger.gci: REGION := P 82 | gafp_ger.gci: IS_DNME := 0 83 | gafp_ger.gci: PATCH_PTR := 8022C874 84 | 85 | gafp_fre.gci: REGION := P 86 | gafp_fre.gci: IS_DNME := 0 87 | gafp_fre.gci: PATCH_PTR := 8022D734 88 | 89 | gafp_spa.gci: REGION := P 90 | gafp_spa.gci: IS_DNME := 0 91 | gafp_spa.gci: PATCH_PTR := 8022C6F4 92 | 93 | gafp_ita.gci: REGION := P 94 | gafp_ita.gci: IS_DNME := 0 95 | gafp_ita.gci: PATCH_PTR := 8022D5F4 96 | 97 | gafu.gci: REGION := U 98 | gafu.gci: IS_DNME := 0 99 | gafu.gci: PATCH_PTR := 8022A0A4 100 | 101 | $(targets): %.gci : %.dat %.pat 102 | @echo " OUTPUT $@" 103 | $(Q)mv -f $(filter %.dat,$^) nesrom/resources/loader.bin 104 | $(Q)$(CA65) nesrom/src/main.asm -g -I nesrom/src --bin-include-dir nesrom -o nesrom/main.o 105 | $(Q)$(LD65) -C nesrom/ldscripts/nes.ld -o nesrom/main.nes -vm nesrom/main.o 106 | $(MKNES) LoadDOL nesrom/main.nes $(REGION) $(IS_DNME) $(filter %.pat,$^) $(PATCH_PTR) 107 | $(Q)mv -f nesrom/LoadDOL_$(REGION)_InjectedData.gci $@ 108 | 109 | dats := gaej_v100.dat gaej_v101.dat gafe.dat gafj_v100.dat gafj_v101.dat gafp_eng.dat gafp_ger.dat gafp_fre.dat gafp_spa.dat gafp_ita.dat gafu.dat 110 | pats := gaej_v100.pat gaej_v101.pat gafe.pat gafj_v100.pat gafj_v101.pat gafp_eng.pat gafp_ger.pat gafp_fre.pat gafp_spa.pat gafp_ita.pat gafu.pat 111 | 112 | $(dats): %.dat: %.elf 113 | @echo " OBJCOPY $@" 114 | $(Q)$(OBJCOPY) -Obinary $< $@ 115 | 116 | elfs := $(dats:.dat=.elf) 117 | 118 | $(elfs): %.elf: %.ld $(objs) 119 | @echo " LINK $@" 120 | $(Q)$(LD) -T $^ -o $@ 121 | 122 | %.o: %.S 123 | @echo " ASSEMBLE $@" 124 | $(Q)$(CC) $(CFLAGS) -c $< -o $@ 125 | 126 | %.o: %.c 127 | @echo " COMPILE $@" 128 | $(Q)$(CC) $(CFLAGS) -c $< -o $@ 129 | 130 | clean: 131 | -rm -f $(targets) $(saves) $(elfs) $(objs) $(slots) $(dats) $(pats) loader.h 132 | -rm -f nesrom/resources/loader.bin nesrom/main.o nesrom/main.nes 133 | -------------------------------------------------------------------------------- /exploit/ac.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018 FIX94 2 | // This code is licensed to you under the terms of the GNU GPL, version 2; 3 | // see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 4 | 5 | #include "loader.h" 6 | 7 | #define TO_ARAM 0 8 | #define TO_MRAM 1 9 | 10 | typedef unsigned int u32; 11 | typedef unsigned short u16; 12 | typedef unsigned char u8; 13 | typedef volatile unsigned int vu32; 14 | typedef volatile unsigned short vu16; 15 | 16 | typedef struct _cInfo 17 | { 18 | int chan; 19 | int fnum; 20 | int offset; 21 | int length; 22 | u16 block; 23 | } cInfo; 24 | 25 | static void sync_cache(void *p, u32 n) 26 | { 27 | u32 start, end; 28 | 29 | start = (u32)p & ~31; 30 | end = ((u32)p + n + 31) & ~31; 31 | n = (end - start) >> 5; 32 | 33 | while (n--) { 34 | asm("dcbst 0,%0 ; icbi 0,%0" : : "b"(p)); 35 | p += 32; 36 | } 37 | asm("sync ; isync"); 38 | } 39 | 40 | void *_memcpy(void *ptr, const void *src, int size) 41 | { 42 | char* ptr2 = ptr; 43 | const char* src2 = src; 44 | while(size--) *ptr2++ = *src2++; 45 | return ptr; 46 | } 47 | 48 | void os_enable_interrupts() 49 | { 50 | asm("mfmsr 3 ; ori 3, 3, 0x8000 ; mtmsr 3"); 51 | } 52 | 53 | void os_disable_interrupts() 54 | { 55 | asm("mfmsr 3 ; rlwinm 3,3,0,17,15 ; mtmsr 3"); 56 | } 57 | 58 | void ar_dma(u32 type, u32 mram, u32 aram, u32 len) 59 | { 60 | //interrupts are enabled so play it safe 61 | os_disable_interrupts(); 62 | while(*(vu16*)0xCC00500A & 0x200) ; 63 | *(vu16*)0xCC005020 = (mram>>16); 64 | *(vu16*)0xCC005022 = (mram&0xFFFF); 65 | *(vu16*)0xCC005024 = (aram>>16); 66 | *(vu16*)0xCC005026 = (aram&0xFFFF); 67 | *(vu16*)0xCC005028 = (type<<15)|(len>>16); 68 | *(vu16*)0xCC00502A = (len&0xFFFF); 69 | while(*(vu16*)0xCC00500A & 0x200) ; 70 | os_enable_interrupts(); 71 | } 72 | 73 | #if 0 74 | #define EXI 0xCC006814 75 | void EXISendByte( char byte ) 76 | { 77 | loop: 78 | *(vu32*)EXI = 0xD0; 79 | *(vu32*)(EXI+0x10) = 0xB0000000 | (byte<<20); 80 | *(vu32*)(EXI+0x0C) = 0x19; 81 | 82 | while( *(vu32*)(EXI+0x0C)&1 ); 83 | 84 | u32 loop = *(vu32*)(EXI+0x10)&0x4000000; 85 | 86 | *(vu32*)EXI = 0; 87 | 88 | if( !loop ) 89 | goto loop; 90 | 91 | return; 92 | } 93 | void pChar(char byte) 94 | { 95 | EXISendByte(byte);EXISendByte('\n'); 96 | } 97 | void pHex(u32 h) 98 | { 99 | int i; 100 | for(i = 28; i >= 0; i-=4) 101 | { 102 | u32 cBit = ((h>>i)&0xF); 103 | if(cBit < 10) 104 | EXISendByte('0'+cBit); 105 | else 106 | EXISendByte('A'+(cBit-10)); 107 | } 108 | EXISendByte('\n'); 109 | } 110 | #else 111 | #define pChar(...) 112 | #define pHex(...) 113 | #endif 114 | 115 | void os_stopaudiosystem(void); 116 | void os_disable_scheduler(void); 117 | int card_getres(int chan); 118 | int card_mountasync(int chan, void* workArea, void *cb1, void *cb2); 119 | int card_unmount(int chan); 120 | int card_open(int chan, const char *path, cInfo *inf); 121 | int card_close(cInfo *inf); 122 | int card_readasync(cInfo *inf, void* addr, int length, int offset, void *cb); 123 | void gx_flush(void); 124 | void gx_abortframe(void); 125 | extern volatile u8 gx_done; 126 | 127 | static void our_gx_drawdone() 128 | { 129 | *(volatile u8*)0xCC008000 = 0x61; 130 | *(volatile u32*)0xCC008000 = 0x45000002; 131 | gx_flush(); 132 | gx_done = 0; 133 | } 134 | 135 | void __attribute__ ((noreturn)) _main() 136 | { 137 | pChar('0'); 138 | //game audio threads are still running 139 | //so we just disable threading to prevent the 140 | //game from randomly crashing on CARD access 141 | os_disable_scheduler(); 142 | //prevent BEEPing 143 | os_stopaudiosystem(); 144 | //setdrawdone not available in jap+ version 145 | //so use this workaround way instead 146 | gx_flush(); 147 | gx_abortframe(); 148 | our_gx_drawdone(); 149 | pChar('1'); 150 | //enable interrupts for GX and CARD access 151 | os_enable_interrupts(); 152 | pChar('2'); 153 | //wait for the GX calls we did to finish 154 | while(gx_done == 0) ; 155 | //game id DOLX00 for boot.dol 156 | *(volatile u32*)0x80000000 = 0x444F4C58; 157 | *(volatile u16*)0x80000004 = 0x3030; 158 | sync_cache((void*)0x80000000, 6); 159 | //re-mount the memory card 160 | card_mountasync(0, (void*)0x81200000, (void*)0, (void*)0); 161 | int res; 162 | //we have interrupts enabled so we will 163 | //know when its not busy anymore luckily 164 | while((res = card_getres(0)) == -1) ; 165 | pChar('3'); 166 | //open up boot.dol from memory card 167 | cInfo mInf; 168 | unsigned int boot_str[3]; boot_str[0] = 0x626F6F74; 169 | boot_str[1] = 0x2E646F6C; boot_str[2] = 0; 170 | card_open(0, ((char*)&boot_str), &mInf); 171 | pChar('4'); 172 | u32 curOffset = 0; 173 | //copy until it returns error 174 | while(card_readasync(&mInf, (void*)0x80001800, 0x200, curOffset, (void*)0) == 0) 175 | { 176 | int res; 177 | //we have interrupts enabled so we will 178 | //know when its not busy anymore luckily 179 | while((res = card_getres(0)) == -1) ; 180 | //this indirectly tells us the file is done 181 | if(res < 0) 182 | break; 183 | sync_cache((void*)0x80001800, 0x200); 184 | ar_dma(TO_ARAM, 0x1800, curOffset, 0x200); 185 | curOffset += 0x200; 186 | } 187 | pChar('5'); 188 | //we are done 189 | card_close(&mInf); 190 | card_unmount(0); 191 | pChar('6'); 192 | //not needed anymore 193 | os_disable_interrupts(); 194 | //copy our loader into mem 195 | _memcpy((void*)0x80001800, loader, loader_size); 196 | sync_cache((void*)0x80001800, loader_size); 197 | pChar('7'); 198 | //jump to it 199 | __asm__ volatile( 200 | "lis 3, 0x8000\n" 201 | "ori 3, 3, 0x1800\n" 202 | "mtlr 3\n" 203 | "blr\n" 204 | ); 205 | __builtin_unreachable(); 206 | } 207 | -------------------------------------------------------------------------------- /exploit/gaej_v100.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8009F020; 11 | os_disable_scheduler = 0x800A3D38; 12 | card_getres = 0x800B4710; 13 | card_mountasync = 0x800B6A04; 14 | card_unmount = 0x800B6C88; 15 | card_open = 0x800B7AE4; 16 | card_close = 0x800B7C00; 17 | card_readasync = 0x800B82DC; 18 | gx_flush = 0x800BC018; 19 | gx_abortframe = 0x800BC1E0; 20 | gx_done = 0x80291D58; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gaej_v101.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8009F7F0; 11 | os_disable_scheduler = 0x800A4500; 12 | card_getres = 0x800B4E44; 13 | card_mountasync = 0x800B7138; 14 | card_unmount = 0x800B73BC; 15 | card_open = 0x800B8218; 16 | card_close = 0x800B8334; 17 | card_readasync = 0x800B8A10; 18 | gx_flush = 0x800BC754; 19 | gx_abortframe = 0x800BC950; 20 | gx_done = 0x802929E0; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafe.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x80079A68; 11 | os_disable_scheduler = 0x8007DD1C; 12 | card_getres = 0x8008E268; 13 | card_mountasync = 0x8009055C; 14 | card_unmount = 0x800907E0; 15 | card_open = 0x800914A4; 16 | card_close = 0x8009161C; 17 | card_readasync = 0x80091CF8; 18 | gx_flush = 0x800957B0; 19 | gx_abortframe = 0x8009580C; 20 | gx_done = 0x80218B88; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafj_v100.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8007B438; 11 | os_disable_scheduler = 0x80082644; 12 | card_getres = 0x8009029C; 13 | card_mountasync = 0x800924F4; 14 | card_unmount = 0x80092778; 15 | card_open = 0x8009343C; 16 | card_close = 0x800935B4; 17 | card_readasync = 0x80093C90; 18 | gx_flush = 0x800975EC; 19 | gx_abortframe = 0x80097648; 20 | gx_done = 0x80217DD8; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafj_v101.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8007B6D4; 11 | os_disable_scheduler = 0x800828E0; 12 | card_getres = 0x80090538; 13 | card_mountasync = 0x80092790; 14 | card_unmount = 0x80092A14; 15 | card_open = 0x800936D8; 16 | card_close = 0x80093850; 17 | card_readasync = 0x80093F2C; 18 | gx_flush = 0x80097888; 19 | gx_abortframe = 0x800978E4; 20 | gx_done = 0x80218318; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafp_eng.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x800801C0; 11 | os_disable_scheduler = 0x80085544; 12 | card_getres = 0x80097D8C; 13 | card_mountasync = 0x8009A0F0; 14 | card_unmount = 0x8009A374; 15 | card_open = 0x8009B1D0; 16 | card_close = 0x8009B2EC; 17 | card_readasync = 0x8009B9C8; 18 | gx_flush = 0x8009F6BC; 19 | gx_abortframe = 0x8009F8B8; 20 | gx_done = 0x8022C8F0; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafp_fre.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x80080080; 11 | os_disable_scheduler = 0x80085404; 12 | card_getres = 0x80097C4C; 13 | card_mountasync = 0x80099FB0; 14 | card_unmount = 0x8009A234; 15 | card_open = 0x8009B090; 16 | card_close = 0x8009B1AC; 17 | card_readasync = 0x8009B888; 18 | gx_flush = 0x8009F57C; 19 | gx_abortframe = 0x8009F778; 20 | gx_done = 0x8022E1D0; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafp_ger.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8007FF60; 11 | os_disable_scheduler = 0x800852E4; 12 | card_getres = 0x80097B2C; 13 | card_mountasync = 0x80099E90; 14 | card_unmount = 0x8009A114; 15 | card_open = 0x8009AF70; 16 | card_close = 0x8009B08C; 17 | card_readasync = 0x8009B768; 18 | gx_flush = 0x8009F45C; 19 | gx_abortframe = 0x8009F658; 20 | gx_done = 0x8022D310; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafp_ita.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8007FF00; 11 | os_disable_scheduler = 0x80085284; 12 | card_getres = 0x80097ACC; 13 | card_mountasync = 0x80099E30; 14 | card_unmount = 0x8009A0B4; 15 | card_open = 0x8009AF10; 16 | card_close = 0x8009B02C; 17 | card_readasync = 0x8009B708; 18 | gx_flush = 0x8009F3FC; 19 | gx_abortframe = 0x8009F5F8; 20 | gx_done = 0x8022E090; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafp_spa.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8007FDE0; 11 | os_disable_scheduler = 0x80085164; 12 | card_getres = 0x800979AC; 13 | card_mountasync = 0x80099D10; 14 | card_unmount = 0x80099F94; 15 | card_open = 0x8009ADF0; 16 | card_close = 0x8009AF0C; 17 | card_readasync = 0x8009B5E8; 18 | gx_flush = 0x8009F2DC; 19 | gx_abortframe = 0x8009F4D8; 20 | gx_done = 0x8022D190; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/gafu.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | . = 0x80004000; 10 | os_stopaudiosystem = 0x8007FBB8; 11 | os_disable_scheduler = 0x800845AC; 12 | card_getres = 0x80096BAC; 13 | card_mountasync = 0x80098EA0; 14 | card_unmount = 0x80099124; 15 | card_open = 0x80099F80; 16 | card_close = 0x8009A09C; 17 | card_readasync = 0x8009A778; 18 | gx_flush = 0x8009E4BC; 19 | gx_abortframe = 0x8009E684; 20 | gx_done = 0x8022AB18; 21 | .exploit : 22 | { 23 | start.o(.start) 24 | *.o(.text) 25 | *.o(.rodata .rodata.*) 26 | *.o(.data) 27 | *.o(.bss) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /exploit/nesrom/README.md: -------------------------------------------------------------------------------- 1 | based off of this nes template, thanks to all the people who made it: 2 | https://github.com/Mikejmoffitt/nes-template -------------------------------------------------------------------------------- /exploit/nesrom/ldscripts/nes.ld: -------------------------------------------------------------------------------- 1 | # CA65 configuration script for UOROM 2 | # Based on Damian Yerrick's original script 3 | # The original copyright information is reproduced at the bottom 4 | # of this linker script. 5 | 6 | MEMORY 7 | { 8 | # RAM 9 | ZEROPAGE: start = 0, size=$100, file=""; 10 | STACK: start = $100, size=$100, file=""; 11 | OAM: start = $200, size=$100, file=""; 12 | RAM: start = $300, size=$500, file=""; 13 | # ROM 14 | HEADER: start = 0, size=$10, fill=yes, fillval=$FF; 15 | ROME: start = $8000, size = $4000, type = ro, file = %O, fill=yes, fillval=$0E; 16 | ROMF: start = $C000, size = $4000, type = ro, file = %O, fill=yes, fillval=$0F; 17 | } 18 | 19 | SEGMENTS 20 | { 21 | ZEROPAGE: load = ZEROPAGE, type=zp; 22 | RAM: load = RAM, type=bss, define = yes, align = $100; 23 | 24 | HEADER: load = HEADER; 25 | 26 | BANKE: load = ROME, type = ro, align = $100, optional = yes; 27 | 28 | BANKF: load = ROMF, type = ro, start = $c000; 29 | VECTORS: load = ROMF, type = ro, start = $fffa; 30 | 31 | } 32 | 33 | # Copyright 2010 Damian Yerrick 34 | # 35 | # Copying and distribution of this file, with or without 36 | # modification, are permitted in any medium without royalty 37 | # provided the copyright notice and this notice are preserved. 38 | # This file is offered as-is, without any warranty. 39 | # 40 | -------------------------------------------------------------------------------- /exploit/nesrom/resources/chr.chr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/resources/chr.chr -------------------------------------------------------------------------------- /exploit/nesrom/resources/nametable.nam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/resources/nametable.nam -------------------------------------------------------------------------------- /exploit/nesrom/resources/nametable2.nam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/resources/nametable2.nam -------------------------------------------------------------------------------- /exploit/nesrom/resources/pal.pal: -------------------------------------------------------------------------------- 1 | #0#0#0#0 -------------------------------------------------------------------------------- /exploit/nesrom/src/cool_macros.asm: -------------------------------------------------------------------------------- 1 | PPUCTRL = $2000 2 | PPUMASK = $2001 3 | PPUSTATUS = $2002 4 | OAMADDR = $2003 5 | OAMDATA = $2004 6 | PPUSCROLL = $2005 7 | PPUADDR = $2006 8 | PPUDATA = $2007 9 | OAMDMA = $4014 10 | DMCFREQ = $4010 11 | 12 | ; A button comparison table for reading joypads 13 | BUTTON_A = %10000000 14 | BUTTON_B = %01000000 15 | BUTTON_SEL = %00100000 16 | BUTTON_START = %00010000 17 | BUTTON_UP = %00001000 18 | BUTTON_DOWN = %00000100 19 | BUTTON_LEFT = %00000010 20 | BUTTON_RIGHT = %00000001 21 | 22 | OAM_BASE = $200 23 | 24 | ; Turn off rendering 25 | .macro ppu_disable 26 | ; Disable rendering 27 | lda #$00 28 | sta PPUMASK 29 | .endmacro 30 | 31 | ; Turn on rendering 32 | .macro ppu_enable 33 | 34 | ; Restore PPUMASK configration. 35 | lda ppumask_config 36 | sta PPUMASK 37 | 38 | ; Re-enable NMI 39 | lda ppuctrl_config 40 | sta PPUCTRL 41 | .endmacro 42 | 43 | ; Switch UNROM/UOROM banks 44 | ; This macro exists to ensure that the data being presented by the PRG ROM 45 | ; chip doesn't conflict with the data the 2A03 is writing to the data bus, as 46 | ; UNROM and UOROM make no provisions to prevent a bus conflict, which could 47 | ; damage one or more driving chips over time if not handled correct. 48 | .macro bank_load num 49 | : 50 | ldy num 51 | sty :- + 1 52 | .endmacro 53 | 54 | ; OAM Access macros 55 | 56 | ; for storing the accumulator (A) as a propery for the specified sprite 57 | .macro write_oam_y idx 58 | sta OAM_BASE+((idx) << 2) 59 | .endmacro 60 | 61 | .macro write_oam_tile idx 62 | sta OAM_BASE+1+((idx) << 2) 63 | .endmacro 64 | 65 | .macro write_oam_attr idx 66 | sta OAM_BASE+2+((idx) << 2) 67 | .endmacro 68 | 69 | .macro write_oam_x idx 70 | sta OAM_BASE+3+((idx) << 2) 71 | .endmacro 72 | 73 | ; Macros to provide a value or address for OAM storage 74 | .macro set_oam_y idx, val 75 | lda val 76 | write_oam_y idx 77 | .endmacro 78 | 79 | .macro set_oam_tile idx, val 80 | lda val 81 | write_oam_tile idx 82 | .endmacro 83 | 84 | .macro set_oam_attr idx, val 85 | lda val 86 | write_oam_attr idx 87 | .endmacro 88 | 89 | .macro set_oam_x idx, val 90 | lda val 91 | write_oam_x idx 92 | .endmacro 93 | 94 | ; Run an OAM DMA 95 | .macro spr_dma 96 | lda #$02 97 | sta OAMDMA 98 | .endmacro 99 | 100 | ; Latch the PPU address; mangles A 101 | .macro ppu_load_addr addr, addr_e 102 | bit PPUSTATUS 103 | lda addr 104 | sta PPUADDR 105 | lda addr_e 106 | sta PPUADDR 107 | .endmacro 108 | 109 | ; Check if a button is held; branch to :+ if not 110 | .macro key_isdown pad, btn_comp 111 | lda pad 112 | bit btn_comp 113 | beq :+ 114 | .endmacro 115 | 116 | ; Check if a button is up; branch to :+ if not 117 | .macro key_isup pad, btn_comp 118 | lda pad 119 | bit btn_comp 120 | bne :+ 121 | .endmacro 122 | 123 | ; Check if a button has just been pressed; branch to :+ if not 124 | .macro key_down pad, btn_comp 125 | lda pad 126 | bit btn_comp 127 | beq :+ 128 | lda pad+1 ;pad_prev 129 | bit btn_comp 130 | bne :+ 131 | .endmacro 132 | 133 | ; Check if a button has just been released; branch to :+ if not 134 | .macro key_up pad, btn_comp 135 | lda pad 136 | bit btn_comp 137 | bne:+ 138 | lda pad+1 ; pad_prev 139 | bit btn_comp 140 | beq :+ 141 | .endmacro 142 | 143 | ; Latch the PPU scroll; mangles A 144 | .macro ppu_load_scroll cam_x, cam_y 145 | bit PPUSTATUS 146 | lda cam_x 147 | sta PPUSCROLL 148 | lda cam_y 149 | sta PPUSCROLL 150 | ; Clamp scroll values 151 | lda xscroll+1 152 | and #%00000001 153 | sta xscroll+1 154 | lda yscroll+1 155 | and #%00000001 156 | sta yscroll+1 157 | 158 | lda ppuctrl_config 159 | ora xscroll+1 ; Bring in X scroll coarse bit 160 | ora yscroll+1 ; Y scroll coarse bit 161 | sta PPUCTRL ; Re-enable NMI 162 | .endmacro 163 | 164 | ; Load a full palette 165 | .macro ppu_load_full_palette pal_data 166 | ppu_load_addr #$3f, #$00 167 | ldx #$00 168 | : 169 | lda pal_data, x 170 | sta PPUDATA 171 | inx 172 | cpx #$20 173 | bne :- 174 | .endmacro 175 | 176 | ; Load a full BG palette 177 | .macro ppu_load_bg_palette pal_data 178 | ppu_load_addr #$3f, #$00 179 | ldx #$00 180 | : 181 | lda pal_data, x 182 | sta PPUDATA 183 | inx 184 | cpx #$10 185 | bne :- 186 | .endmacro 187 | 188 | ; Load a full SPR palette 189 | .macro ppu_load_spr_palette pal_data 190 | ppu_load_addr #$3f, #$10 191 | ldx #$00 192 | : 193 | lda pal_data, x 194 | sta PPUDATA 195 | inx 196 | cpx #$10 197 | bne :- 198 | .endmacro 199 | 200 | ; Add a 16-bit memory value to addr 201 | .macro sum16 addr, val 202 | clc 203 | lda addr 204 | adc val 205 | sta addr 206 | lda addr+1 207 | adc val+1 208 | sta addr+1 209 | .endmacro 210 | 211 | .macro sub16 addr, amt 212 | sec 213 | lda addr 214 | sbc amt 215 | sta addr 216 | lda addr+1 217 | sbc amt+1 218 | sta addr+1 219 | .endmacro 220 | 221 | ; Negate a 16-bit address 222 | .macro neg16 addr 223 | sec 224 | lda #$00 225 | sbc addr 226 | sta addr 227 | lda #$00 228 | sbc addr+1 229 | sta addr+1 230 | .endmacro 231 | 232 | ; Copy binary nametable + attribute data into VRAM 233 | 234 | .macro ppu_write_8kbit source, index 235 | ldy index ; Upper byte of VRAM Address 236 | ldx #$00 ; Lower byte of VRAM Address 237 | 238 | bit PPUSTATUS 239 | sty PPUADDR 240 | stx PPUADDR 241 | 242 | ; X is the offset in both the source table and the nametable destination. 243 | ; PPUADDR increments with every write to PPUDATA, so an unrolled two-level 244 | ; nested loop becomes four single loops, taking us through the source 245 | ; table in four chunks. 246 | 247 | : 248 | lda source, x ; Offset within both source and dest. 249 | sta PPUDATA 250 | inx 251 | bne :- 252 | : 253 | lda source + $100, x ; Offset within both source and dest. 254 | sta PPUDATA 255 | inx 256 | bne :- 257 | : 258 | lda source + $200, x ; Offset within both source and dest. 259 | sta PPUDATA 260 | inx 261 | bne :- 262 | : 263 | lda source + $300, x ; Offset within both source and dest. 264 | sta PPUDATA 265 | inx 266 | bne :- 267 | .endmacro 268 | 269 | .macro ppu_write_32kbit source, index 270 | ldy index ; Upper byte of VRAM Address 271 | ldx #$00 ; Lower byte of VRAM Address 272 | 273 | bit PPUSTATUS 274 | sty PPUADDR 275 | stx PPUADDR 276 | 277 | ; X is the offset in both the source table and the nametable destination. 278 | ; PPUADDR increments with every write to PPUDATA, so an unrolled two-level 279 | ; nested loop becomes four single loops, taking us through the source 280 | ; table in four chunks. 281 | 282 | : 283 | lda source, x ; Offset within both source and dest. 284 | sta PPUDATA 285 | inx 286 | bne :- 287 | : 288 | lda source + $100, x ; Offset within both source and dest. 289 | sta PPUDATA 290 | inx 291 | bne :- 292 | : 293 | lda source + $200, x ; Offset within both source and dest. 294 | sta PPUDATA 295 | inx 296 | bne :- 297 | : 298 | lda source + $300, x ; Offset within both source and dest. 299 | sta PPUDATA 300 | inx 301 | bne :- 302 | : 303 | lda source + $400, x ; Offset within both source and dest. 304 | sta PPUDATA 305 | inx 306 | bne :- 307 | : 308 | lda source + $500, x ; Offset within both source and dest. 309 | sta PPUDATA 310 | inx 311 | bne :- 312 | : 313 | lda source + $600, x ; Offset within both source and dest. 314 | sta PPUDATA 315 | inx 316 | bne :- 317 | : 318 | lda source + $700, x ; Offset within both source and dest. 319 | sta PPUDATA 320 | inx 321 | bne :- 322 | : 323 | lda source + $800, x ; Offset within both source and dest. 324 | sta PPUDATA 325 | inx 326 | bne :- 327 | : 328 | lda source + $900, x ; Offset within both source and dest. 329 | sta PPUDATA 330 | inx 331 | bne :- 332 | : 333 | lda source + $a00, x ; Offset within both source and dest. 334 | sta PPUDATA 335 | inx 336 | bne :- 337 | : 338 | lda source + $b00, x ; Offset within both source and dest. 339 | sta PPUDATA 340 | inx 341 | bne :- 342 | : 343 | lda source + $c00, x ; Offset within both source and dest. 344 | sta PPUDATA 345 | inx 346 | bne :- 347 | : 348 | lda source + $d00, x ; Offset within both source and dest. 349 | sta PPUDATA 350 | inx 351 | bne :- 352 | : 353 | lda source + $e00, x ; Offset within both source and dest. 354 | sta PPUDATA 355 | inx 356 | bne :- 357 | : 358 | lda source + $f00, x ; Offset within both source and dest. 359 | sta PPUDATA 360 | inx 361 | bne :- 362 | .endmacro 363 | -------------------------------------------------------------------------------- /exploit/nesrom/src/header.asm: -------------------------------------------------------------------------------- 1 | .segment "HEADER" 2 | 3 | ; Borrowed from https://github.com/furrykef/pacman 4 | 5 | ; Magic cookie 6 | .byte "NES", $1a 7 | 8 | ; Size of PRG in 16 KB units 9 | .byte 2 10 | 11 | ; Size of CHR in 8 KB units (0 = CHR RAM) 12 | .byte 0 13 | 14 | ; Mirroring, save RAM, trainer, mapper low nybble 15 | .byte $21 ; UNROM 16 | 17 | ; Vs., PlayChoice-10, NES 2.0, mapper high nybble 18 | .byte $00 19 | 20 | ; Size of PRG RAM in 8 KB units 21 | .byte 0 22 | 23 | ; NTSC/PAL 24 | .byte $00 25 | -------------------------------------------------------------------------------- /exploit/nesrom/src/main.asm: -------------------------------------------------------------------------------- 1 | ; iNES Header 2 | .include "header.asm" 3 | 4 | ; ============================= 5 | ; Zero-page and main RAM 6 | ; Variables, flags, etc. 7 | ; ============================= 8 | .segment "ZEROPAGE" 9 | ; Fast variables 10 | temp: .res 1 11 | temp2: .res 1 12 | temp3: .res 1 13 | temp4: .res 1 14 | temp5: .res 1 15 | temp6: .res 1 16 | temp7: .res 1 17 | temp8: .res 1 18 | pad_1: .res 1 19 | pad_1_prev: .res 1 20 | pad_2: .res 1 21 | pad_2_prev: .res 1 22 | 23 | .segment "RAM" 24 | ; Flags for PPU control 25 | ppumask_config: .res 1 26 | ppuctrl_config: .res 1 27 | vblank_flag: .res 1 28 | xscroll: .res 2 29 | yscroll: .res 2 30 | 31 | ; Some useful macros 32 | .include "cool_macros.asm" 33 | 34 | ; ============================ 35 | ; PRG bank F 36 | ; 37 | ; Bank F is hardwired to $C000 - $FFFF, and is where the boot code resides. 38 | ; Subsequently all code in Bank F is accessible when any bank is active. Common 39 | ; utility code should go here. 40 | ; ============================ 41 | .segment "BANKF" 42 | .include "utils.asm" 43 | 44 | ; ============================ 45 | ; NMI ISR 46 | ; This is run once per frame - it will allow any function spinning on the 47 | ; vblank_flag variable to proceed. 48 | ; 49 | ; For frame synchronization, call wait_nmi: 50 | ; 51 | ; jsr wait_nmi 52 | ; ============================ 53 | nmi_vector: 54 | pha ; Preseve A 55 | 56 | lda #$00 57 | sta PPUCTRL ; Disable NMI 58 | sta vblank_flag 59 | 60 | lda #$80 ; Bit 7, VBlank activity flag 61 | @vbl_done: 62 | bit PPUSTATUS ; Check if vblank has finished 63 | bne @vbl_done ; Repeat until vblank is over 64 | 65 | lda #%10011011 66 | sta PPUCTRL ; Re-enable NMI 67 | 68 | pla ; Restore registers from stack 69 | 70 | rti 71 | 72 | ; ============================ 73 | ; IRQ ISR 74 | ; Unused; can be wired to cartridge for special hardware. The UNROM mapper does 75 | ; not use the IRQ pin for anything like scanline interrupts or timers, etc. 76 | ; ============================ 77 | irq_vector: 78 | rti 79 | 80 | ; ============================ 81 | ; Entry vector 82 | ; ============================ 83 | 84 | reset_vector: 85 | ; Basic 6502 init, straight outta NESDev 86 | sei ; ignore IRQs 87 | cld ; No decimal mode, it isn't supported 88 | ldx #%00000100 89 | stx $4017 ; Disable APU frame IRQ 90 | 91 | ldx #$ff 92 | txs ; Set up stack 93 | 94 | ; Clear some PPU registers 95 | inx ; X = 0 now 96 | stx PPUCTRL ; Disable NMI 97 | stx PPUMASK ; Disable rendering 98 | stx DMCFREQ ; Disable DMC IRQs 99 | 100 | ; Set an upper bank 101 | bank_load #$00 102 | 103 | ; Wait for first vblank 104 | @waitvbl1: 105 | lda #$80 106 | bit PPUSTATUS 107 | bne @waitvbl1 108 | 109 | ; Wait for the PPU to go stable 110 | txa ; X still = 0; clear A with this 111 | @clrmem: 112 | sta $000, x 113 | sta $100, x 114 | ; Reserving $200 for OAM display list 115 | sta $300, x 116 | sta $400, x 117 | sta $500, x 118 | sta $600, x 119 | 120 | inx 121 | bne @clrmem 122 | 123 | ; One more vblank 124 | @waitvbl2: 125 | lda #$80 126 | bit PPUSTATUS 127 | bne @waitvbl2 128 | 129 | ; PPU configuration for actual use 130 | ldx #%10001000 ; Nominal PPUCTRL settings: 131 | ; NMI enable 132 | ; Slave mode (don't change this!) 133 | ; 8x8 sprites 134 | ; BG at $0000 135 | ; SPR at $1000 136 | ; VRAM auto-inc 1 137 | ; Nametable at $2000 138 | stx ppuctrl_config 139 | stx PPUCTRL 140 | 141 | ldx #%00011110 142 | stx ppumask_config 143 | stx PPUMASK 144 | 145 | ppu_enable 146 | 147 | jmp main_entry ; GOTO main loop 148 | 149 | ; ============================================================================= 150 | ; ==== ==== 151 | ; ==== Program Begin ==== 152 | ; ==== ==== 153 | ; ============================================================================= 154 | main_entry: 155 | 156 | ; The PPU must be disabled before we write to VRAM. This is done during 157 | ; the vertical blanking interval typically, so we do not need to blank 158 | ; the video in the middle of a frame. 159 | ppu_disable 160 | 161 | ; Clear sprites 162 | jsr spr_init 163 | 164 | ; Put scroll at 0, 0 165 | bit PPUSTATUS 166 | lda #$00 167 | sta PPUSCROLL ; X scroll 168 | sta PPUSCROLL ; Y scroll 169 | 170 | ; Switch the upper half of PRG memory to Bank E (please see note below) 171 | bank_load #$0E 172 | 173 | ; Load in a palette 174 | ppu_load_bg_palette sample_palette_data 175 | 176 | ; Load in CHR tiles to VRAM for BG 177 | ; Remember, BG data starts at $0000 - we must specify the upper byte of 178 | ; the destination address ($00). 179 | ppu_write_32kbit sample_chr_data, #$00 180 | 181 | ; and for sprites, which start at $1000. 182 | ppu_write_32kbit sample_chr_data + $1000, #$10 183 | 184 | ; Wait a few frames 185 | jsr wait_nmi 186 | jsr wait_nmi 187 | jsr wait_nmi 188 | jsr wait_nmi 189 | jsr wait_nmi 190 | 191 | ; Check if exploit triggered 192 | lda exploit_succeeded_byte 193 | cmp #$01 194 | beq success 195 | 196 | fail: 197 | ; Finally, bring in a nametable so the background will draw something. 198 | ; The first nametable begins at $2000, so we specify $20(00). 199 | ppu_write_8kbit sample_nametable_data, #$20 200 | 201 | ; Duplicate the nametable into the other screen as well. 202 | ppu_write_8kbit sample_nametable_data, #$24 203 | 204 | clv 205 | bvc after_nt 206 | 207 | success: 208 | ; Finally, bring in a nametable so the background will draw something. 209 | ; The first nametable begins at $2000, so we specify $20(00). 210 | ppu_write_8kbit sample_nametable_data2, #$20 211 | 212 | ; Duplicate the nametable into the other screen as well. 213 | ppu_write_8kbit sample_nametable_data2, #$24 214 | 215 | after_nt: 216 | ; Bring the PPU back up. 217 | jsr wait_nmi 218 | ppu_enable 219 | 220 | main_top_loop: 221 | 222 | ; Run game logic here 223 | 224 | ; End of game logic frame; wait for NMI (vblank) to begin 225 | jsr wait_nmi 226 | 227 | ; Commit VRAM updates while PPU is disabled in vblank 228 | ;ppu_disable 229 | 230 | ; Re-enable PPU for the start of a new frame 231 | ;ppu_enable 232 | jmp main_top_loop; loop forever 233 | 234 | ; While our main code is in Bank F, the simple palette data (colors), 235 | ; CHR data (graphics), and Nametable data (layout) is located in another 236 | ; bank. 237 | ; Addresses $C000-$FFFF are hardwired to Bank F in the 2A03's data space "PRG", 238 | ; but the upper half of ROM space at $8000-BFFF can be switched out when the 239 | ; programmer desires. 240 | .segment "BANKE" 241 | 242 | exploit_succeeded_byte: 243 | .byte $00 244 | 245 | exploit_data: 246 | .incbin "resources/loader.bin" 247 | 248 | ; The sample graphics resources. 249 | sample_chr_data: 250 | .incbin "resources/chr.chr" 251 | 252 | sample_nametable_data: 253 | .incbin "resources/nametable.nam" 254 | 255 | sample_nametable_data2: 256 | .incbin "resources/nametable2.nam" 257 | 258 | sample_palette_data: 259 | .byte $0F, $01, $23, $30 260 | .byte $0F, $01, $23, $30 261 | .byte $0F, $01, $23, $30 262 | .byte $0F, $01, $23, $30 263 | ; For a large project, palette data like this is often separated 264 | ; into a separate file and .incbin'd in, just like the other data. 265 | 266 | ; These are needed to boot the NES. 267 | .segment "VECTORS" 268 | 269 | .addr nmi_vector ; Every vblank, this ISR is executed. 270 | .addr reset_vector ; On bootup or reset, execution begins here. 271 | .addr irq_vector ; Triggered by external hardware in the 272 | ; game cartridge, this ISR is executed. A 273 | ; software break (BRK) will do it as well. 274 | -------------------------------------------------------------------------------- /exploit/nesrom/src/nes.asm: -------------------------------------------------------------------------------- 1 | ; Borrowed from https://github.com/furrykef/pacman 2 | 3 | ; These are fairly standard names 4 | PPUCTRL = $2000 5 | PPUMASK = $2001 6 | PPUSTATUS = $2002 7 | OAMADDR = $2003 8 | OAMDATA = $2004 9 | PPUSCROLL = $2005 10 | PPUADDR = $2006 11 | PPUDATA = $2007 12 | OAMDMA = $4014 13 | 14 | ; These are names I made up 15 | SQ1VOL = $4000 16 | SQ1SWP = $4001 17 | SQ1FREQ = $4002 18 | SQ1LEN = $4003 19 | SQ2VOL = $4004 20 | SQ2SWP = $4005 21 | SQ2FREQ = $4006 22 | SQ2LEN = $4007 23 | TRICNTR = $4008 24 | ; nothing at $4009 25 | TRIFREQ = $400a 26 | TRILEN = $400b 27 | NOISEVOL = $400c 28 | ; Nothing at $400d 29 | NOISEFREQ = $400e 30 | NOISELEN = $400f 31 | DMCFREQ = $4010 32 | DMCDELTA = $4011 33 | DMCADDR = $4012 34 | DMCLEN = $4013 35 | ; $4014 is handled above 36 | CHANCTRL = $4015 37 | JOY1 = $4016 ; when reading 38 | JOYSTROBE = $4016 ; when writing 39 | JOY2 = $4017 ; when reading 40 | APUIRQ = $4017 ; when writing 41 | 42 | 43 | ; Controller buttons 44 | JOY_A = $01 45 | JOY_B = $02 46 | JOY_SELECT = $04 47 | JOY_START = $08 48 | JOY_UP = $10 49 | JOY_DOWN = $20 50 | JOY_LEFT = $40 51 | JOY_RIGHT = $80 52 | -------------------------------------------------------------------------------- /exploit/nesrom/src/utils.asm: -------------------------------------------------------------------------------- 1 | .segment "BANKF" 2 | 3 | wait_nmi: 4 | lda vblank_flag 5 | bne wait_nmi ; Spin here until NMI lets us through 6 | lda #$01 7 | sta vblank_flag 8 | rts 9 | 10 | ; Controller reading code from NESDev 11 | ; Out: A=buttons pressed, where bit 0 is A button 12 | read_joypads: 13 | ; Strobe controller 14 | lda #1 15 | sta $4016 16 | sta pad_2 17 | lsr a 18 | sta $4016 19 | : 20 | lda $4016 21 | and #$03 22 | cmp #$01 23 | rol pad_1 24 | lda $4017 25 | and #$03 26 | cmp #$01 27 | rol pad_2 28 | bcc :- 29 | rts 30 | 31 | ; temp is a zero-page variable 32 | 33 | ; Reads controller. Reliable when DMC is playing. 34 | ; Out: A=buttons held, A button in bit 0 35 | read_joy_safe: 36 | ; Back up previous ones for edge comparisons 37 | lda pad_1 38 | sta pad_1_prev 39 | lda pad_2 40 | sta pad_2_prev 41 | ; Get first reading 42 | jsr read_joypads 43 | : 44 | ; Save previous reading 45 | lda pad_1 46 | sta temp 47 | lda pad_2 48 | sta temp2 49 | 50 | ; Read again and compare. If they differ, 51 | ; read again. 52 | jsr read_joypads 53 | lda pad_1 54 | cmp temp 55 | bne :- 56 | lda pad_2 57 | cmp temp2 58 | bne :- 59 | rts 60 | 61 | ; Clear the OAM table 62 | spr_init: 63 | ldx #$00 64 | lda #$FF 65 | @clroam_loop: 66 | sta OAM_BASE, x 67 | inx 68 | cpx #$00 69 | bne @clroam_loop 70 | rts 71 | -------------------------------------------------------------------------------- /exploit/nesrom/tools/ACNESCreator.CommandLine.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/ACNESCreator.CommandLine.exe -------------------------------------------------------------------------------- /exploit/nesrom/tools/ACNESCreator.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/ACNESCreator.Core.dll -------------------------------------------------------------------------------- /exploit/nesrom/tools/GCNToolKit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/GCNToolKit.dll -------------------------------------------------------------------------------- /exploit/nesrom/tools/README.md: -------------------------------------------------------------------------------- 1 | ACNESCreator was compiled from this fork: 2 | https://github.com/FIX94/ACNESCreator 3 | which is nearly identical to the original, thanks Cuyler36: 4 | https://github.com/Cuyler36/ACNESCreator 5 | ca65 and ld65 were already in the original nes template -------------------------------------------------------------------------------- /exploit/nesrom/tools/ca65: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/ca65 -------------------------------------------------------------------------------- /exploit/nesrom/tools/ca65.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/ca65.exe -------------------------------------------------------------------------------- /exploit/nesrom/tools/ld65: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/ld65 -------------------------------------------------------------------------------- /exploit/nesrom/tools/ld65.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/exploit/nesrom/tools/ld65.exe -------------------------------------------------------------------------------- /exploit/start.S: -------------------------------------------------------------------------------- 1 | // Copyright 2018 FIX94 2 | // This code is licensed to you under the terms of the GNU GPL, version 2; 3 | // see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 4 | 5 | .section .start,"ax" 6 | .globl _start 7 | 8 | _start: 9 | // Disable interrupts 10 | mfmsr 3 ; rlwinm 3,3,0,17,15 ; mtmsr 3 ; isync 11 | 12 | // Set up a stack frame. 13 | lis 1,0x8000 ; addi 1,1,0x3000 ; li 0,0 ; stwu 0,-64(1) 14 | 15 | // Go for it! 16 | b _main 17 | -------------------------------------------------------------------------------- /patcher/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 FIX94 2 | # This code is licensed to you under the terms of the GNU GPL, version 2; 3 | # see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 4 | 5 | 6 | # Configuration: 7 | 8 | # What toolchain prefix should we use 9 | CROSS ?= powerpc-eabi- 10 | 11 | # End of configuration. 12 | 13 | 14 | 15 | # Set CC, LD, OBJCOPY based on CROSS, unless they are set already 16 | 17 | ifeq ($(origin CC), default) 18 | CC := $(CROSS)gcc -m32 19 | endif 20 | ifeq ($(origin LD), default) 21 | LD := $(CROSS)ld 22 | endif 23 | OBJCOPY ?= $(CROSS)objcopy 24 | 25 | 26 | # The compiler flags we need. 27 | 28 | CFLAGS := -Wall -W -O1 -fPIC -ffreestanding -mno-eabi -mno-sdata -mcpu=750 29 | 30 | 31 | # Build with "V=1" to see the commands executed; be quiet otherwise. 32 | 33 | ifeq ($(V),1) 34 | Q := 35 | else 36 | Q := @ 37 | MAKEFLAGS += --no-print-directory 38 | endif 39 | 40 | 41 | targets := gaej_v100.pat gaej_v101.pat gafe.pat gafj_v100.pat gafj_v101.pat gafp_eng.pat gafp_ger.pat gafp_fre.pat gafp_spa.pat gafp_ita.pat gafu.pat 42 | 43 | objs := start.o 44 | 45 | all: $(targets) 46 | 47 | $(targets): %.pat: %.elf 48 | @echo " OUTPUT $@" 49 | $(Q)$(OBJCOPY) -Obinary $< $@ 50 | 51 | elfs := $(targets:.pat=.elf) 52 | 53 | $(elfs): %.elf: %.ld $(objs) 54 | @echo " LINK $@" 55 | $(Q)$(LD) -T $^ -o $@ 56 | 57 | %.o: %.S 58 | @echo " ASSEMBLE $@" 59 | $(Q)$(CC) $(CFLAGS) -c $< -o $@ 60 | 61 | clean: 62 | -rm -f $(targets) $(elfs) $(objs) 63 | -------------------------------------------------------------------------------- /patcher/gaej_v100.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x8021EB4C; 10 | PATCHER_VAL_2 = 0x8114341C; 11 | PATCHER_VAL_3 = 0x81295F4C; 12 | PATCHER_VAL_4 = 0x81143484; 13 | PATCHER_VAL_5 = 0x800B0400; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gaej_v101.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x8022090C; 10 | PATCHER_VAL_2 = 0x811438BC; 11 | PATCHER_VAL_3 = 0x812964EC; 12 | PATCHER_VAL_4 = 0x81143924; 13 | PATCHER_VAL_5 = 0x800B0B28; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafe.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x801F6C64; 10 | PATCHER_VAL_2 = 0x806BF5BC; 11 | PATCHER_VAL_3 = 0x8128E97C; 12 | PATCHER_VAL_4 = 0x806BF624; 13 | PATCHER_VAL_5 = 0x8008AEB0; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafj_v100.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x801EF9C8; 10 | PATCHER_VAL_2 = 0x807122C4; 11 | PATCHER_VAL_3 = 0x81280284; 12 | PATCHER_VAL_4 = 0x80712328; 13 | PATCHER_VAL_5 = 0x8008C8F4; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafj_v101.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x801EFF08; 10 | PATCHER_VAL_2 = 0x80712C64; 11 | PATCHER_VAL_3 = 0x81280744; 12 | PATCHER_VAL_4 = 0x80712CC8; 13 | PATCHER_VAL_5 = 0x8008CB90; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafp_eng.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x8020690C; 10 | PATCHER_VAL_2 = 0x80FFEEF4; 11 | PATCHER_VAL_3 = 0x811202DC; 12 | PATCHER_VAL_4 = 0x80FFEF5C; 13 | PATCHER_VAL_5 = 0x80093878; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafp_fre.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x802081EC; 10 | PATCHER_VAL_2 = 0x81001F24; 11 | PATCHER_VAL_3 = 0x811239FC; 12 | PATCHER_VAL_4 = 0x81001F8C; 13 | PATCHER_VAL_5 = 0x80093738; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafp_ger.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x8020732C; 10 | PATCHER_VAL_2 = 0x81000F94; 11 | PATCHER_VAL_3 = 0x8112275C; 12 | PATCHER_VAL_4 = 0x81000FFC; 13 | PATCHER_VAL_5 = 0x80093618; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafp_ita.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x802080AC; 10 | PATCHER_VAL_2 = 0x8100194C; 11 | PATCHER_VAL_3 = 0x81122F7C; 12 | PATCHER_VAL_4 = 0x810019B4; 13 | PATCHER_VAL_5 = 0x800935B8; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafp_spa.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x802071AC; 10 | PATCHER_VAL_2 = 0x81000D34; 11 | PATCHER_VAL_3 = 0x8112255C; 12 | PATCHER_VAL_4 = 0x81000D9C; 13 | PATCHER_VAL_5 = 0x80093498; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/gafu.ld: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 FIX94 2 | This code is licensed to you under the terms of the GNU GPL, version 2; 3 | see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ 4 | 5 | OUTPUT_FORMAT("elf32-powerpc") 6 | OUTPUT_ARCH(powerpc:common) 7 | 8 | SECTIONS { 9 | PATCHER_VAL_1 = 0x80204B6C; 10 | PATCHER_VAL_2 = 0x8070E6DC; 11 | PATCHER_VAL_3 = 0x812CD43C; 12 | PATCHER_VAL_4 = 0x8070E744; 13 | PATCHER_VAL_5 = 0x800928BC; 14 | .exploit : 15 | { 16 | start.o(.start) 17 | *.o(.text) 18 | *.o(.rodata .rodata.*) 19 | *.o(.data) 20 | *.o(.bss) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /patcher/start.S: -------------------------------------------------------------------------------- 1 | 2 | .section .start,"ax" 3 | 4 | #r12 contains _start abs addr 5 | _start: 6 | b begin #at 0x00(r12), jump to our code of course 7 | #this will be filled in the linker file 8 | .long PATCHER_VAL_1 #at 0x04(r12), rom pointer (loader source) 9 | .long PATCHER_VAL_2 #at 0x08(r12), pointer to overwrite with loader entry 10 | .long PATCHER_VAL_3 #at 0x0C(r12), game state that will be used when exiting nes 11 | .long PATCHER_VAL_4 #at 0x10(r12), array that controls what save state we are on 12 | .long PATCHER_VAL_5 #at 0x14(r12), PADSetSpec address to restore pointer 13 | begin: 14 | #grab padread return address 15 | mflr %r6 16 | #save padread args 17 | mr %r7, %r3 18 | mr %r8, %r4 19 | mr %r9, %r5 20 | #grab rom pointer 21 | lwz %r3, 4(%r12) 22 | lwz %r3, 0(%r3) 23 | cmplwi %r3, 0 24 | beq exit 25 | #store exploit success for rom 26 | li %r0, 1 27 | stb %r0, 0x10(%r3) 28 | #move to actual loader 29 | addi %r3, %r3, 0x11 30 | #loader destination 31 | lis %r4, 0x8000 32 | ori %r4, %r4, 0x4000 33 | #just copy over 0x1000 bytes for the loader 34 | li %r5, 0x1000 35 | cpyloop: 36 | cmpwi %r5, 0 37 | beq cpyend 38 | lbz %r0, 0(%r3) 39 | stb %r0, 0(%r4) 40 | addi %r3, %r3, 1 41 | addi %r4, %r4, 1 42 | subi %r5, %r5, 1 43 | b cpyloop 44 | cpyend: 45 | #pointer we will replace 46 | lwz %r4, 0x8(%r12) 47 | #write in loader entry 48 | lis %r3, 0x8000 49 | ori %r3, %r3, 0x4000 50 | stw %r3, 0(%r4) 51 | #state we will replace 52 | lwz %r4, 0xC(%r12) 53 | #set state to save game 54 | li %r3, 0x22 55 | stw %r3, 0(%r4) 56 | #speed up save progress 57 | lwz %r4, 0x10(%r12) 58 | #get pointer to save function 59 | lwz %r3, 8(%r4) 60 | #execute it immediately 61 | stw %r3, 0(%r4) 62 | exit: 63 | #get PADSetSpec address 64 | lwz %r4, 0x14(%r12) 65 | #grab originally set spec 66 | lha %r3, 0x5A(%r4) 67 | #use original spec as arg 68 | lwzx %r3, %r3, %r13 69 | #call PADSetSpec 70 | mtctr %r4 71 | bctrl 72 | #intended function in r0 thanks 73 | #to PADSetSpec leaving it behind 74 | mr %r12, %r0 75 | mtctr %r12 76 | #restore padread return address 77 | mtlr %r6 78 | #restore padread args 79 | mr %r3, %r7 80 | mr %r4, %r8 81 | mr %r5, %r9 82 | #call intended function 83 | bctr 84 | -------------------------------------------------------------------------------- /town/README.md: -------------------------------------------------------------------------------- 1 | just started the game, saved at the earliest possibility and then inserted a NES right in the house entrance using this tool, thanks Cuyler36: 2 | https://github.com/Cuyler36/ACSE -------------------------------------------------------------------------------- /town/gaej.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/gaej.gci -------------------------------------------------------------------------------- /town/gafe.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/gafe.gci -------------------------------------------------------------------------------- /town/gafj.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/gafj.gci -------------------------------------------------------------------------------- /town/gafp.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/gafp.gci -------------------------------------------------------------------------------- /town/gafu.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/gafu.gci -------------------------------------------------------------------------------- /town/unedited/gaej.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/unedited/gaej.gci -------------------------------------------------------------------------------- /town/unedited/gafe.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/unedited/gafe.gci -------------------------------------------------------------------------------- /town/unedited/gafj.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/unedited/gafj.gci -------------------------------------------------------------------------------- /town/unedited/gafp.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/unedited/gafp.gci -------------------------------------------------------------------------------- /town/unedited/gafu.gci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FIX94/ac-exploit-gc/1d935e45929fa0d059267f42a3bcaf063b797df5/town/unedited/gafu.gci --------------------------------------------------------------------------------