Advertisement
pigdevil2010

Dream Red Battle Transition

Apr 17th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; by pigdevil2010
  2. ; memory address corresponds to Patch 4.7.1
  3. ; TPPRedTransitionTiles is http://i.imgur.com/RdK7Xvb.png
  4.  
  5. BattleTransition_TPPRed: ; b69c7 (2d:69c7)
  6.     ; duration may not be accurate because of some
  7.     ; long-running codes like random tiles generation
  8.    
  9.     ; prepare for animation #1
  10.     ; duration - 7 frames (0.12 seconds)
  11.    
  12.     ld hl, vChars2 + $500 ; $9500 | tile number $50
  13.     ld de, TPPRedTransitionTiles ; $607d
  14.     ld bc, (BANK(TPPRedTransitionTiles) << 8) + $08 ; $2d08 | bank $2d, 8 tiles long
  15.     call CopyVideoDataDouble ; $1899
  16.     xor a
  17.     ld [H_AUTOBGTRANSFERDEST], a ; $ffbc
  18.     ld [hSCX], a ; $ffae
  19.     ld [hSCY], a ; $ffaf
  20.    
  21.     ld a, vBGMap0 / $100 ; $98
  22.     ld [H_AUTOBGTRANSFERDEST + 1], a ; $ffbd
  23.     ld a, 1 ; enable automatic background transfer
  24.     ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
  25.     call Delay3 ; $3e0a | copy current tiles to the BGMap0 too
  26.     ld a, $90 ; get rid of a window, it will be used for black scrolling
  27.     ld [hWY], a ; $ffb0
  28.     ld a, vBGMap1 / $100 ; $9c
  29.     ld [H_AUTOBGTRANSFERDEST + 1], a ; $ffbd
  30.     ; fill BGMap1 with black tiles
  31.     ld hl, wTileMap ; $c3a0
  32.     ld bc, 20 * 18
  33.     ld a, $57 ; black tile
  34.     call FillMemory ; $377b
  35.     call Delay3 ; $3e0a | wait for transfer to complete
  36.    
  37.     ; animation #1 - black wipe from bottom
  38.     ; duration - 48 frames (0.8 seconds)
  39.    
  40.     ld b, $90
  41. .anim1loop
  42.     call DelayFrame ; $20cb
  43.     ld a, b
  44.     ld [hWY], a ; $ffb0
  45.     sub 3
  46.     ld b, a
  47.     jr nc, .anim1loop
  48.     xor a
  49.     ld [hWY], a ; $ffb0
  50.     call DelayFrame ; $20cb
  51.    
  52.     ; prepare for animation #2
  53.     ; duration - 6 frames (0.1 seconds)
  54.    
  55.     ld a, vBGMap0 / $100 ; $98
  56.     ld [H_AUTOBGTRANSFERDEST + 1], a ; $ffbd
  57.     call GenRandomCommandTiles ; $6a57
  58.     call Delay3 ; $3e0a | wait for transfer to complete
  59.     ; since wTileMap is only 18 rows long, we need to do this
  60.     ; because the BG map is 32 rows long
  61.     ld a, (vBGMap0 + $1c0) / $100 ; $99
  62.     ld [H_AUTOBGTRANSFERDEST + 1], a ; $ffbd
  63.     ld a, (vBGMap0 + $1c0) % $100 ; $c0
  64.     ld [H_AUTOBGTRANSFERDEST], a ; $ffbc
  65.     call GenRandomCommandTiles ; $6a57
  66.     call Delay3 ; $3e0a wait for transfer to complete
  67.     xor a
  68.     ld [H_AUTOBGTRANSFERENABLED], a ; $ffba | no more transfers needed now
  69.    
  70.     ; animation #2 - revealing the command chaos
  71.     ; duration - 144 frames (2.4 seconds)
  72.    
  73.     ld bc, 0 ; b = hWY, c = frame count
  74.     ld de, $1 ; d = hSCY, e = rate
  75. .anim2loop
  76.     call DelayFrameWithCommandChaos ; $6a77
  77.     ld a, b
  78.     ld [hWY], a ; $ffb0
  79.     inc b
  80.     ld a, b
  81.     cp $90
  82.     jr nz, .anim2loop
  83.     ld [hWY], a ; $ffb0
  84.    
  85.     ; animation #3 - increasing the command chaos speed
  86.     ; duration - 288 frames (4.8 seconds)
  87.    
  88.     ld c, 0 ; reset the counter
  89. .anim3loop
  90.     call DelayFrameWithCommandChaos ; $6a77
  91.     ld a, c
  92.     and $1f ; increase every 32 frames
  93.     jr nz, .anim3loop
  94.     inc e
  95.     ld a, e
  96.     cp 10 ; do this until the rate is 9
  97.     jr nz, .anim3loop
  98.    
  99.     ; restore the original transfer destination
  100.     ld a, vBGMap1 / $100 ; $9c
  101.     ld [H_AUTOBGTRANSFERDEST + 1], a ; $ffbd
  102.     xor a
  103.     ld [H_AUTOBGTRANSFERDEST], a ; $ffbc
  104.     jp GBFadeOutToWhite ; $20f4
  105.    
  106. GenRandomCommandTiles: ; b6a57 (2d:6a57)
  107.     ; used for TPP Red battle transition
  108.     ld hl, wTileMap ; c3a0
  109.     ld d, 20 * 18 / 2
  110. .loop
  111.     ; quick dsum random
  112.     ld a, [rDIV] ; $ff04
  113.     ld b, a
  114.     ld a, [hRandomAdd] ; $ffd3
  115.     adc b
  116.     ld [hRandomAdd], a ; $ffd3
  117.     ld b, a
  118.    
  119.     ld a, b
  120.     and $7 ; 8 tiles
  121.     add $50 ; tile number $50 - $57
  122.     ld [hli], a
  123.     ld a, b
  124.     swap a
  125.     and $7
  126.     add $50
  127.     ld [hli], a
  128.     dec d
  129.     jr nz, .loop
  130.     ret
  131.    
  132. DelayFrameWithCommandChaos: ; b6a77 (2d:6a77)
  133.     ; used for TPP Red battle transition
  134.     inc c
  135.     ld a, d
  136.     add e
  137.     ld [hSCY], a ; $ffaf
  138.     ld d, a
  139.     jp DelayFrame ; $20cb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement