KDLPro

Weather Image Display Implementation

Oct 20th, 2021
664
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. GetWeatherImage:
  2.     ld a, [wBattleWeather]
  3.     dec a
  4.     jr z, .rain
  5.     dec a
  6.     jr z, .sun
  7.     dec a
  8.     jr z, .sand
  9.     ; dec a
  10.     ; jr z, .hail
  11.     ld a, [wTimeOfDay]
  12.     cp 2
  13.     jr z, .clear_night
  14.     jr .clear_day
  15.    
  16. .rain
  17.     farcall SetPalettes_Rain
  18.     ld de, RainWeatherImage
  19.     lb bc, PAL_BATTLE_OB_BROWN, 8
  20.     jr z, .done
  21.    
  22. .sun
  23.     farcall SetPalettes_Sun
  24.     ld de, SunWeatherImage
  25.     lb bc, PAL_BATTLE_OB_BROWN, 8
  26.     jr z, .done
  27.    
  28. .hail
  29.     farcall SetPalettes_Hail
  30.     ld de, HailWeatherImage
  31.     lb bc, PAL_BATTLE_OB_BROWN, 8
  32.     jr z, .done
  33.    
  34. .sand
  35.     farcall SetPalettes_Sand
  36.     ld de, SandstormWeatherImage
  37.     lb bc, PAL_BATTLE_OB_BROWN, 8
  38.     jr z, .done
  39.    
  40. .clear_day
  41.     farcall SetPalettes_ClearDay
  42.     ld de, ClearDayWeatherImage
  43.     lb bc, PAL_BATTLE_OB_BROWN, 8
  44.     jr z, .done
  45.  
  46. .clear_night
  47.     farcall SetPalettes_ClearNight
  48.     ld de, ClearNightWeatherImage
  49.     lb bc, PAL_BATTLE_OB_BROWN, 8
  50.    
  51. .done
  52.     push bc
  53.     ld b, BANK(WeatherImages) ; c = 4
  54.     ld hl, vTiles0 tile $04
  55.     call Request2bpp
  56.     pop bc
  57.     ld hl, wVirtualOAMSprite04
  58.     ld de, .WeatherImageOAMData
  59. .loop
  60.     ld a, [de]
  61.     inc de
  62.     ld [hli], a
  63.     ld a, [de]
  64.     inc de
  65.     ld [hli], a
  66.     dec c
  67.     ld a, c
  68.     ld [hli], a
  69.     ld a, b
  70.     ld [hli], a
  71.     jr nz, .loop
  72.     ret
  73.  
  74. .WeatherImageOAMData
  75. ; positions are backwards since
  76. ; we load them in reverse order
  77.     db $88, $1c ; y/x - bottom right
  78.     db $88, $14 ; y/x - bottom left
  79.     db $80, $1c ; y/x - top right
  80.     db $80, $14 ; y/x - top left
RAW Paste Data