SHARE
TWEET

Optimized Untitled

ISSOtm Sep 4th, 2017 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. calculatePalette:
  2.   ; Get the current line
  3.   ld b, 0
  4.   ld a, [rLY]
  5.   ld c, a
  6.  
  7.   ; Get sin(Ly/PI) or SinLyPiTable[b] if you want to see it as an array.
  8.   ld hl, SinLyPiTable
  9.   add hl, bc
  10.   ld d, [hl]
  11.  
  12.  
  13.   ; Multiply by 2 or 4
  14.   ld a, [wScale]
  15.   ld b, a
  16.   and a
  17.   ld a, d
  18.   jr z, _noScale
  19. _multiply:
  20.   add a, a
  21.   dec b
  22.   jr nz, _multiply
  23.  
  24.   jr _noDownScale
  25.  
  26. _noScale:
  27.   ; Scale back down ( / 8)
  28.   and %11111000
  29.   rrca
  30.   rrca
  31.   rrca
  32. _noDownScale:
  33.  
  34.   ; Use the result to change the palette
  35.   and %00000011
  36.   cpl
  37.   ldh [< rBGP], a
  38. ret
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!
 
Top