[Draft] Game Boy "Game-Reboot" PoC

ISSOtm Dec 3rd, 2016 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *** DISCLAIMER ***
  3. This "exploit" uses obscure and heavily unintended hardware behavior. NEVER deviate from any instruction given here, otherwise you could corrupt your save data from either cartridge, corrupt the program from either cartridge, or damage your Game Boy.
  4. If you didn't follow the steps listed here and something went wrong, don't complain.
  5. If you did but something went wrong, or you think you found out something new/interesting, post something about it. We love that. Also, we are active on this forum, and do our best to answer quickly.
  7. Also please, read the first three sections before doing anything. You'll be at risk to miss some info or additional features (yep there are).
  9. Now, please enjoy your stay.
  13. ** Proof Of Concept "Game Re-boot" 8F Setup & Method **
  15. Now, here is a setup based on a mix of TheZZAZZGlitch's ideas and my previous post.
  17. This is a PoC item pack setup that should be used like so :
  18. 1. Plug Pokémon R/B
  19. 2. Run 8F setup
  20. 3. Remove cartridge. Nothing should happen.
  21. 4. Plug any other cartridge. It should boot right away !
  23. Here is the 8F setup, starting from the first item in the inventory pack. WARNING ! This setup relies on the value of register DE. See comment below.
  24. Quantities noted in parentheses are ways to obtain those required ; a "+ 128" means "duplicate using MissingNo", a "- XX" means "toss XX of it".
  26. 8F
  27. Item x[qty]
  28. TM43 x99
  29. Antidote x106 (= 1 + 128 - 23)
  30. Escape Rope x26
  31. Soda Pop x60
  32. Fire Stone x251 (= 1 + 128 - 6 + 128)
  33. Poké Ball x26
  34. Fresh Water x61
  35. Rare Candy x251
  36. Lemonade x17
  37. TM33 x[any qty] / Great Ball x233 (= 1 + 128 - 24 + 128)
  38. ; Nope, this is not TM33 ACE, guys.
  42. ** Things to note **
  44. 1. I did not try this on any hardware ! I don't have 8F on my cartridge right now. (Soon, though)
  45. As such, I assumed all memory reads from the cartridge will return $00 when it has been removed.
  46. BUT it may return $FF instead, which will make this setup NOT work.
  47. However, if that is the case, it will be trivial to change the setup, so no worries.
  48. 2. This cannot be tested on emulators (AFAIK)
  49. 3. This assumes you have a GBC / GBA. More below.
  50. 4.This does NOT work on GBAs, since they have a tiny switch in the cartridge slot that switches the Game Boy between GBA and GBC compatibility.
  53. (Images sourced from IGN)
  54. I tried powering the console without a cartridge having the switch "clicked" using a DS stylus, and releasing it while the GBC ROM was running. Apparently the display goes fully black, but the GBC tune still played. "Clicking" the switch again didn't do anything.
  55. 5. This may not work right with some cartridges that expect some values when booting, since this setup does the minimum to ensure the game is properly given control.
  56. Most games with a "Soft Reset" option (like Pokémon with START+SELECT+A+B) or something similar should work fine.
  57. 6. Since this bypasses the GB "checksum check", this allows you to play some old, pirate, badly bootlegged cartridges !
  58. 7. Apparently this may NOT work on a DMG, unless you have extreme luck. ([url=]Source, read the comments[/url])
  59. [quote author=Gameboygenius]
  60. @MelonStorm @vxbinaca Yes, there's a blocking bar on DMG (the first Gameboy.) But not only that. You will almost always crash the DMG when you remove the cartridge. I believe the reason for this is CMOS latchup. How they fixed this on GBC, if you open up the unit and look inside, is by moving the ground ping closer to the cartridge so it makes first and breaks last when you insert/remove the cartridge.
  61. [/quote]
  62. [quote author=furrtek]
  63. @Gameboygenius I'll have to get a DMG for testing then, I plan on using this for a game. Works fine on the GB Pocket and I don't see any difference in the placement of the contacts on the GBC slot.
  64. [/quote]
  69. ** Value of A / Number of Lemonades : Changing Consoles **
  71. This will let you change the "model" of Game Boy you will be using, provided the game you use cares.
  72. An example of this is Pokémon Gold, Silver and Crystal, which behave differently on GBs and GBC/As.
  74. Here are the values the register A usually holds when the GBx leaves control to the game :
  75. $01  SGB or Normal Gameboy (DMG)
  76. $FF  SGB2 or Pocket Gameboy
  77. $11  CGB or GBA
  79. However, some games (such as Shantae and, apparently, Zelda Oracle of Ages/Seasons, see ROM0:0158 for "bit 0, b" or [url=]this disassembly[/url]) differentiate GBC and GBA by checking Bit 0 (parity) of the B register.
  80. This bit is cleared by the GBC boot ROM, whereas the GBA sets it.
  81. The above setup leaves this bit undefined. (Technical details below)
  82. What you can do to force either GBC or GBA is :
  83. [list type=decimal]
  84. [li]Put a Bicycle x1 right after the 17 Lemonades near the end of the setup. For those wondering : this translates into a "ld b, 1". I can't manipulate the quantity (except through heavy glitching) because it is a key item.[/li]
  85. [li]This will force GBA mode.[/li]
  86. [li]To instead force GBC mode, put 4 or 5 Burn / Ice Heals right after the Bicycle. Before it WON'T WORK.[/li]
  87. [/list]
  90. * Effects of "faking" a console *
  92. This has yet to be tested, since Pokémon Red and Blue make GBCs boot into "DMG (grey GB) mode", which removes GBC features. Effects will differ with Pokémon Yellow, which has GBC compatibility (check ROM0:0143, where $00 means "No GBC", $80 means "Maybe GBC", and $C0 means "GBC only")
  94. When a game detects GBA, it usually applies different color palettes to compensate for a skewed color mixing (red tones are different on GBC and GBA).
  95. Sometimes exclusive content is sometimes unlocked ; for example, Shantae gives you the Tinkerbat form only if you are playing on a GBA ([url=]Source[/url])
  98. * Undefined B *
  100. The problem is that 8F setups usually modify B, and as such, B's value upon starting the new game will depend on the setup, but only on the setup.
  102. So, B's value is undefined, yet consistent : it will be that same every time you run the script.
  103. The Bicycle x1 sets B to 1, which has bit 0 set ; the Burn / Ice Heals x4 increment B, setting it to 2, which has bit 0 clear (whereas x5 decrements it, still clearing bit 0)
  108. ** GBz80 code **
  110. When this code begins, register DE should equal $0001. If a setup is used that modifies DE... this won't work. The current 5- and 6-Pokémon setups work fine.
  112. ; We NEED to disable interrupts because they run from ROM.
  113. ; Servicing an interrupt before the cartridge is pulled will result in ROM being executed (and that's exactly what we're trying to avoid)
  114. ; Servicing an interrupt after the cartridge is pulled will result in execution NOP-sliding into VRAM. And we definitely don't want that.
  115. di
  117. ; It is a pain to execute any "jp $xxxx" because of the three consecutive bytes and uncooperative item translations, so we will do a "jp (hl)" instead.
  118. ; As such, we need to set hl up.
  119. ; This one setup is smaller than one padding instruction, then loading a value into H and another into L, then modifying DE,
  120. ; *probably* saving one item slot.
  121. ld h, e ; hl = $0122
  122. dec bc ; Padding byte (harmless)
  123. ld l, d ; hl = $0100, where the GB leaves execution after startup (usually a NOP followed by a JP to the game's bootstrap)
  124. dec e ; de = $0000, which will be our "reference byte" address, which we will constantly poll to
  126. ; Now, we need to wait until a new cartridge is inserted.
  127. ; To do so, we first read the byte at ($0000), which is $FF in Pokémon Red/Blue.
  128. ; We will simply wait until it's not the case anymore.
  129. .waitCartRemoved
  130. ld a,(de)
  131. dec a
  132. inc a ; don't modify A, but update the Z flag
  133. jr nz, waitCartRemoved (@-4, @+$FC)
  135. inc b ; Padding byte
  137. ; Assuming all reads from ROM
  138. .waitCartInserted
  139. ld a,(de)
  140. inc a
  141. dec a
  142. jr z, waitCardInserted
  144. ld a, $11 ; games use this value to identify GBC (see G/S/C Glitch Dimension)
  146. ( dec bc ) ; if Great Ball
  147. jp (hl) ; We jump to the memory location the GB gives control to at startup
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!