Advertisement
Guest User

Pokémon Yellow credits routine

a guest
Mar 25th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. After the rating:
  2.  
  3. 4F2E -> make the screen white
  4.  
  5. 4F31 -> set C to 0x64
  6. 4F33 -> wait C frames (if called directly, C will be 0x00 and it waits 256 frames)
  7.  
  8. 4F36 -> LCD stuff
  9.  
  10. 4F39 -> set A to 0xA7
  11. 4F3B -> set x position of the window to A (if called directly, A will be 0x3B and everything will be off)
  12.  
  13. 4F3D -> set A to 0x00
  14. 4F3E -> set "Background Horizontal Scrolling" to A
  15. 4F40 -> set "Background Vertical Scrolling" to A
  16. 4F42 -> set $FFAE to A
  17. 4F44 -> set $FFAF to A
  18. 4F46 -> set $FFB0 to A
  19. 4F48 -> set y position of the window to A
  20.  
  21. 4F4A -> upload text graphics
  22.  
  23. 4F4D -> set HL to 0xC3A0
  24. 4F50 -> set 0x4F bytes starting from HL to 0x7E (top black bar)
  25. 4F53 -> set HL to 0xC4B8
  26. 4F56 -> set 0x4F bytes starting from HL to 0x7E (bottom black bar)
  27.  
  28. 4F59 -> set A to 0xC0
  29. 4F5B -> set the background palette to A
  30.  
  31. 4F5D -> ??? (it has something to do with palettes and it works with values at around $DEE0 to $DFC0)
  32.  
  33. 4F60 -> enable LCD operation (which was disabled at the end of $4F36)
  34.  
  35. 4F63 -> sound stuff
  36.  
  37. 4F66 -> set HL to 0x9C00
  38. 4F69 -> copy the screen in RAM into the window at (HL)
  39. 4F6C -> set HL to 0x9800
  40. 4F6F -> copy background (I guess?) in RAM into the background at (HL)
  41.  
  42. 4F72 -> set C to 0x1F
  43. 4F74 -> set A to 0xC7
  44. 4F76 -> sound stuff (it also fills various parts at $C0xx with 0x00 and 0x01)
  45.  
  46. 4F79 -> set C to 0x80
  47. 4F7B -> wait C frames
  48.  
  49. 4F7E -> set A to 0x00
  50. 4F7F -> set $CD3D to A
  51. 4F82 -> set $CD3E to A
  52. 4F85 -> jump to $50B6
  53.  
  54. 50B6 -> set DE to 0x5171
  55. 50B9 -> push DE
  56.  
  57. 50BA -> pop DE
  58. 50BB -> set HL to 0xC421
  59. 50BE -> push HL
  60. 50BF -> make the screen white (copy 0x7F to $C3F0 - $C4B7)
  61.  
  62. 50C2 -> pop HL
  63.  
  64. / 50C3 -> set A to (DE)
  65. | 50C4 -> DE += 1
  66. | 50C5 -> push DE
  67. |
  68. | 50C6 - 50DC -> if A is 0xFF/0xFE/0xFD/0xFC/0xFB/0xFA then jump to $50EF/$50F6/$5100/$5107/$50E4/$510E
  69. | 50DE -> get the next line to write (pointer is at (DE))
  70. | 50E1 -> pop DE
  71. \ 50E2 -> jump to $50C3
  72.  
  73. if 0xFB:
  74. 50E4:06 01 LD B,#01h
  75. 50E6:21 40 43 LD HL,#4340h
  76. 50E9:CD 84 3E CALL #3E84h
  77. 50EC:D1 POP DE
  78. 50ED:18 D4 JR 50C3h
  79.  
  80. if 0xFF:
  81. 50EF:CD 88 4F CALL #4F88h <- 4F: LD C,A
  82. 50F2:0E 66 LD C,#66h
  83. 50F4:18 02 JR 50F8h
  84.  
  85. if 0xFE:
  86. 50F6:0E 7A LD C,#7Ah
  87. 50F8:CD 2F 37 CALL #372Fh
  88. 50FB:CD A4 4F CALL #4FA4h
  89. 50FE:18 BA JR 50BAh
  90.  
  91. if 0xFD:
  92. 5100:CD 88 4F CALL #4F88h
  93. 5103:0E 84 LD C,#84h
  94. 5105:18 02 JR 5109h
  95.  
  96. if 0xFC:
  97. 5107:0E 98 LD C,#98h
  98. 5109:CD 2F 37 CALL #372Fh
  99. 510C:18 AC JR 50BAh
  100.  
  101. if 0xFA:
  102. 510E:CD 13 51 CALL #5113h
  103. 5111:D1 POP DE
  104. 5112:C9 RET
  105.  
  106. Our code directly jumps into a "special case" (normally tested at $50C6 - $50DC) at $50F1. This would explain the garbage screen at the start, because text is only updated at such a case.
  107. It then goes into the normal loop where it reads the value at (DE). That value normally is set to 0x50B6, but we skipped that part.
  108. Our DE is set to 0x0D5D just before the jump to $50F1 and it isn't changed after that (only +1 at $50C4 to get the next line of text).
  109. So wrong values are loaded, but remember, the game waits for a "special case" to update text. The first value starting from $0D5D which gives a special case is 0xFA, which is the "THE END" case.
  110. Now the code jumps to $510E and executes the normal code for the "THE END" screen.
  111. After the return at $5112 the game eventually reaches $0D4C.
  112. It accesses the bank pointer at $D35D and jumps to the word stored in $D36D.
  113. In our case this is bank 0x3C and address $50F1.
  114. Since just before the jump DE is set to 0x0D5D, it results in an infinite loop, which always shows "THE END".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement