Advertisement
pigdevil2010

Tustin's PC (a.k.a. TPP inside Pokemon Red)

Aug 4th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TustinsPC: ; Tustin's PC. Where the TPP minigame located.
  2.     db $8
  3.     ld a, [wd78e]
  4.     bit 0, a
  5.     ld hl, TustinsPCNotAvailable
  6.     jr z, .nopc
  7.     jr .pcready
  8. .nopc
  9.     call PrintText
  10.     jp TextScriptEnd
  11. .pcready
  12.     ld hl, TustinsPCOn
  13.     call PrintText
  14.     call YesNoChoice
  15.     ld hl, TustinsPCNo
  16.     ld a, [wCurrentMenuItem]
  17.     and a
  18.     jp nz, .nopc
  19.     ; Start the TPP minigame
  20.     ld a, 2
  21.     ld [wcd50], a
  22.     predef EmotionBubble
  23.     call LoadFontTilePatterns
  24.     ld hl, TustinsPCYes
  25.     call PrintText
  26.     ; Clear counters
  27.     ; Counter structure: 0 | A | B | S | R | L | U | D
  28.     ; The first byte is always set to 0 to prevent cinnabar shore abuse
  29.     xor a
  30.     ld hl, W_GRASSRATE
  31.     ld bc, 8
  32.     call FillMemory
  33. .inputloop
  34.     ld a, [hJoyInput]
  35.     ld c, a
  36.     cp b
  37.     jr z, .inputloop ; No new button detected
  38.     jr c, .updatelastbtn ; a < b. Means that some buttons are released
  39.     ; There's a new button!
  40.     sub b ; Get a newly pressed button
  41.     ld hl, W_GRASSMONS
  42.     bit 0, a
  43.     jr z, .noA
  44.     call IncIfLessThan250
  45. .noA
  46.     inc hl
  47.     bit 1, a
  48.     jr z, .noB
  49.     call IncIfLessThan250
  50. .noB
  51.     inc hl
  52.     bit 3, a
  53.     jr z, .nostart
  54.     call IncIfLessThan250
  55. .nostart
  56.     inc hl
  57.     bit 4, a
  58.     jr z, .noR
  59.     call IncIfLessThan250
  60. .noR
  61.     inc hl
  62.     bit 5, a
  63.     jr z, .noL
  64.     call IncIfLessThan250
  65. .noL
  66.     inc hl
  67.     bit 6, a
  68.     jr z, .noU
  69.     call IncIfLessThan250
  70. .noU
  71.     inc hl
  72.     bit 7, a
  73.     jr z, .noD
  74.     call IncIfLessThan250
  75. .noD
  76.     bit 2, a
  77.     jr nz, .stop
  78. .updatelastbtn
  79.     ld b, c
  80.     jr .inputloop
  81. .stop
  82.     ld hl, TustinsPCStop
  83.     call PrintText
  84.     ld bc, W_GRASSRATE
  85.     ld hl, TustinsPC251A
  86.     call Compare251bci
  87.     jr z, .lotA
  88.     ld hl, TustinsPCPressedA
  89. .lotA
  90.     call PrintText
  91.     ld hl, TustinsPC251B
  92.     call Compare251bci
  93.     jr z, .lotB
  94.     ld hl, TustinsPCPressedB
  95. .lotB
  96.     call PrintText
  97.     ld hl, TustinsPC251S
  98.     call Compare251bci
  99.     jr z, .lotS
  100.     ld hl, TustinsPCPressedS
  101. .lotS
  102.     call PrintText
  103.     ld hl, TustinsPC251R
  104.     call Compare251bci
  105.     jr z, .lotR
  106.     ld hl, TustinsPCPressedR
  107. .lotR
  108.     call PrintText
  109.     ld hl, TustinsPC251L
  110.     call Compare251bci
  111.     jr z, .lotL
  112.     ld hl, TustinsPCPressedL
  113. .lotL
  114.     call PrintText
  115.     ld hl, TustinsPC251U
  116.     call Compare251bci
  117.     jr z, .lotU
  118.     ld hl, TustinsPCPressedU
  119. .lotU
  120.     call PrintText
  121.     ld hl, TustinsPC251D
  122.     call Compare251bci
  123.     jr z, .end
  124.     ld hl, TustinsPCPressedD
  125. .end
  126.     call PrintText
  127.     jp TextScriptEnd
  128.    
  129. IncIfLessThan250: ; Don't increment if the stored value is greater than 250, else do it.
  130.     push af
  131.     ld a, [hl]
  132.     cp 251
  133.     jr z, .skip
  134.     inc [hl]
  135. .skip
  136.     pop af
  137.     ret
  138.    
  139. Compare251bci:
  140.     inc bc
  141.     ld a, [bc]
  142.     cp 251
  143.     ret
  144.    
  145. TustinsPCPressedA:
  146.     TX_FAR _TustinsPCPressedA
  147.     db "@"
  148.    
  149. TustinsPCPressedB:
  150.     TX_FAR _TustinsPCPressedB
  151.     db "@"
  152.    
  153. TustinsPCPressedS:
  154.     TX_FAR _TustinsPCPressedS
  155.     db "@"
  156.    
  157. TustinsPCPressedR:
  158.     TX_FAR _TustinsPCPressedR
  159.     db "@"
  160.    
  161. TustinsPCPressedL:
  162.     TX_FAR _TustinsPCPressedL
  163.     db "@"
  164.    
  165. TustinsPCPressedU:
  166.     TX_FAR _TustinsPCPressedU
  167.     db "@"
  168.    
  169. TustinsPCPressedD:
  170.     TX_FAR _TustinsPCPressedD
  171.     db "@"
  172.    
  173. TustinsPC251A:
  174.     TX_FAR _TustinsPC251A
  175.     db "@"
  176.    
  177. TustinsPC251B:
  178.     TX_FAR _TustinsPC251B
  179.     db "@"
  180.    
  181. TustinsPC251S:
  182.     TX_FAR _TustinsPC251S
  183.     db "@"
  184.    
  185. TustinsPC251R:
  186.     TX_FAR _TustinsPC251R
  187.     db "@"
  188.    
  189. TustinsPC251L:
  190.     TX_FAR _TustinsPC251L
  191.     db "@"
  192.    
  193. TustinsPC251U:
  194.     TX_FAR _TustinsPC251U
  195.     db "@"
  196.    
  197. TustinsPC251D:
  198.     TX_FAR _TustinsPC251D
  199.     db "@"
  200.  
  201. TustinsPCNotAvailable:
  202.     TX_FAR _TustinsPCNotAvailable
  203.     db "@"
  204.    
  205. TustinsPCOn:
  206.     TX_FAR _TustinsPCOn
  207.     db "@"
  208.  
  209. TustinsPCYes:
  210.     TX_FAR _TustinsPCYes
  211.     db "@"
  212.    
  213. TustinsPCNo:
  214.     TX_FAR _TustinsPCNo
  215.     db "@"
  216.    
  217. TustinsPCStop:
  218.     TX_FAR _TustinsPCStop
  219.     db "@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement