Reprogrammation GameBoy en raison d'un bug dans Pokemon Yellow

Pokemon Yellow est un univers de poche avec ses propres rĂšgles. Dans celui-ci, vous pouvez acheter et vendre des objets, entraĂźner des PokĂ©mon, vaincre d'autres entraĂźneurs - mais vous ne pouvez pas changer les rĂšgles du jeu lui-mĂȘme. Vous ne pouvez pas vous construire une maison, changer votre musique ou mĂȘme changer vos vĂȘtements. Plus prĂ©cisĂ©ment, c'Ă©tait prĂ©vu de cette façon. En fait, il existe une sĂ©quence de commandes valides (comme se dĂ©placer d'un endroit Ă  un autre et manipuler des objets) qui vous permet de transformer le jeu en Pacman, Tetris, Pong, lecteur MIDI, etc.





Il y a un speedrun Felipe Lopes de Freitas (p4wn3r) , dans lequel Pokemon Yellow est terminé en 1 minute 36 secondes. Ce speedrun est basé sur le hack suivant: Normalement, l'inventaire du joueur est limité à 20 objets. Mais il existe un bug qui permet d'ignorer cette limitation et de traiter la mémoire située immédiatement aprÚs l'inventaire comme s'il s'agissait d'une liste d'éléments. En conséquence, la manipulation d'objets standard permet de réécrire cette mémoire. Speedrunner profite de cette opportunité pour forcer la porte de la salle de départ à le transférer à l'emplacement final, dans lequel il ne peut qu'écouter les félicitations.





Quand j'ai vu ce speedrun pour la premiĂšre fois et que j'ai rĂ©alisĂ© que la mĂ©moire Gameboy pouvait ĂȘtre manipulĂ©e avec juste une liste d'Ă©lĂ©ments, sans aucun outil externe, j'ai dĂ©cidĂ© de voir si je pouvais amĂ©liorer les techniques de p4wn3r. Voici ce qui s'est passĂ©:





Gameboy — . , — , . , [62 16 37 224 47 240 37 230 15 55]



, , , A. , - , . - ( ) Gameboy — , (, ) Pokemon Yellow. 





-, ? , (, , ..) :





item-one-id         (0-255)
item-one-quantity   (0-255)
item-two-id         (0-255)
item-two-quantity   (0-255)
.
.
.
      
      



, :





lemonade     x16
guard spec.  x224
leaf stone   x240
guard spec.  x230
parlyz heal  x55
      
      



— . , , ID . - , , 2-3 . , , 92 ; , .





— , . , , , , . , , .





!

, Lp/k. , . , , p4wn3r: , . 8 10 , 20- ( ). Celadon Dept. store. p4wn3r “ ” , .





, 0x00, . , 0xFF 0x00 . , , . 255 0x00- . 2 0x00 414925 , :





+-------------------+----------+
|##| Item           | Quantity |
+--+----------------+----------+
|1 | TM02           |  98      |
|2 | TM37           |  71      |
|3 | TM05           |   1      |
|4 | TM09           |   1      |
|5 | burn-heal      |  12      |
|6 | ice-heal       |  55      |
|7 | parlyz-heal    |  99      |
|8 | parlyz-heal    |  55      |
|9 | TM18           |   1      |
|10| fire-stone     |  23      |
|11| water-stone    |  29      |
|12| x-accuracy     |  58      |
|13| guard-spec     |  99      |
|14| guard-spec     |  24      |
|15| lemonade       |  16      |
|16| TM13           |   1      |
+--+----------------+----------+
      
      



, . — . , , A, B, start select. 4 ; 200 , , . , 8 , . , , , , .





, Celadon mansion ( , ). . , , . , , .





, Gameboy (, ) . — , . http://hg.bortreb.com/vba-clojure





, , vba-rerecording. C, Java JNI. : Gameboy, . , Java .





JNI clojure, vba-rerecording. , C . , , , . , . , , Viridian City :





(defn-memo viridian-store->oaks-lab
  ([] (viridian-store->oaks-lab
       (get-oaks-parcel)))
  ([script]
     (->> script
          (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
                 ← ← ← ← ← ← ← ← ← 
                 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
                 ← ←
                 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
                 ↓ ↓ ↓ ↓ ↓ ↓ ↓
                 → → → → → → → →
                 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
                 ← ← ← ← ←
                 ↓ ↓ ↓ ↓
                 ])
          (walk-thru-grass
           [↓ ↓ ↓ ↓ ↓ ↓ ↓])
          (walk [↓ ↓ ← ↓ ↓ ↓ ←
                 ↓ ↓ ↓ ↓ ↓ ↓
                 → → → ↑])
                
          (do-nothing 1))))

      
      



, :





(defn-memo hacking-10
  ([] (hacking-10 (hacking-9)))
  ([script]
     (->> script
          begin-deposit
          (deposit-held-item 17 230)
          (deposit-held-item-named :parlyz-heal 55)
          (deposit-held-item 14 178)
          (deposit-held-item-named :water-stone 29)
          (deposit-held-item 14 32)
          (deposit-held-item-named :TM18 1)
          (deposit-held-item 13 1)
          (deposit-held-item 13 191)
          (deposit-held-item-named :TM02 98)
          (deposit-held-item-named :TM09 1)
          close-menu)))
      
      



, , . , , 99. , :





(defn pc-item-writer-program







  []







  (let [;;limit 75







        limit 201 ;; (item-hack 201 is the smallest I could make this.) 







        [target-high target-low] (disect-bytes-2 pokemon-list-start)]







    (flatten







     [[0x00  ;; (item-hack) no-op (can't buy repel (1E) at celadon)







       0x1E  ;; load limit into E







       limit







       0x3F  ;; (item-hack) set carry flag no-op







       ;; load 2 into C.







       0x0E   ;; C == 1 means input-first nybble







       0x04   ;; C == 0 means input-second nybble







       0x21 ;; load target into HL







       target-low







       target-high







       0x37 ;; (item-hack) set carry flag no-op







       0x00 ;; (item-hack) no-op







       0x37 ;; (item-hack) set carry flag no-op







       0x00 ;; (item-hack) no-op







       0xF3 ;; disable interrupts







       ;; Input Section







       0x3E ;; load 0x20 into A, to measure buttons







       0x10 







       0x00 ;; (item-hack) no-op







       0xE0 ;; load A into [FF00]







       0x00







       0xF0 ;; load 0xFF00 into A to get







       0x00 ;; button presses







       





       0xE6







       0x0F ;; select bottom four bits of A







       0x37 ;; (item-hack) set carry flag no-op







       0x00 ;; (item-hack) no-op







       0xB8 ;; see if input is different (CP A B)







       0x00 ;; (item-hack) (INC SP)







       0x28 ;; repeat above steps if input is not different







       ;; (jump relative backwards if B != A)







       0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37)







       0x47 ;; load A into B







              0x0D ;; dec C





       0x37 ;; (item-hack) set-carry flag







       ;; branch based



on C:





       0x20 ;; JR NZ







       23 ;; skip "input second nybble" and "jump to target" below







       ;; input second nybble







       0x0C ;; inc C







       0x0C ;; inc C







       0x00 ;; (item-hack) no-op







       0xE6 ;; select bottom bits







       0x0F







       0x37 ;; (item-hack) set-carry flag no-op







       0x00 ;; (item-hack) no-op







       0xB2 ;; (OR A D) -> A







       0x22 ;; (do (A -> (HL)) (INC HL))







       0x1D ;; (DEC E)







       0x00 ;; (item-hack) 







       0x20 ;; jump back to input section if not done







       0xDA ;; literal -36 == TM 18 (counter)







       0x01 ;; (item-hack) set BC to literal (no-op)







       ;; jump to target







       0x00  ;; (item-hack) these two bytes can be anything.







       0x01 







       0x00   ;; (item-hack) no-op







       0xBF   ;; (CP A A) ensures Z







       0xCA   ;; (item-hack) jump if Z







       target-low







       target-high







       0x01   ;; (item-hack) will never be reached.







       ;; input first nybble







       0x00







       0xCB







       0x37  ;; swap nybbles on A







       0x57  ;; A -> D







       0x37  ;; (item-hack) set carry flag no-op







       0x18  ;; relative jump backwards







       0xCD  ;; literal -51 == TM05; go back to input section







       0x01  ;; (item-hack) will never reach this instruction







       ]







      (repeat 8 [0x00 0x01]);; these can be anything







      [;; jump to actual program







       0x00







       0x37  ;; (item-hack) set carry flag no-op







       0x2E  ;; 0x3A -> L







       0x3A







       0x00  ;; (item-hack) no-op







       0x26  ;; 0xD5 -> L







       0xD5  







       0x01  ;; (item-hack) set-carry BC







       0x00  ;; (item-hack) these can be anything







       0x01  







       0x00







       0xE9 ;; jump to (HL)







- 0x00 0xFF. 0x00 , , . 0x00 — NO-OP, , . 0xFF . : , , , , :





pokeball x2
      
      



- 0xFF, , :





pokeball x1
pokeball x1
pokeball x1
      
      



0xFF . 





, Gameboy, — . MIDI, GameBoy, http://www.everyponysings.com/. MIDI-, . — PNG- Gameboy- , . , , ( http://hg.bortreb.com/vba-clojure).








All Articles