Advertisement
VladislavSavvateev

Untitled

Nov 5th, 2020
3,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------
  2. ; Green Hill Zone background layer deformation code
  3. ; ---------------------------------------------------------------------------
  4.  
  5. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  6.  
  7.  
  8. Deform_GHZ:
  9.     ; calculate Y position
  10.         lea (v_hscrolltablebuffer).w,a1
  11.         move.w  (v_screenposy).w,d0
  12.         andi.w  #$7FF,d0
  13.         lsr.w   #5,d0
  14.         neg.w   d0
  15.         addi.w  #$20,d0
  16.         bpl.s   @limitY
  17.         moveq   #0,d0
  18.     @limitY:
  19.         move.w  d0,d4
  20.         move.w  d0,(v_bgscrposy_dup).w
  21.         move.w  (v_screenposx).w,d0
  22.         cmpi.b  #id_Title,(v_gamemode).w
  23.         bne.s   @notTitle
  24.         moveq   #0,d0   ; reset foreground position in title screen
  25.     @notTitle:
  26.         neg.w   d0
  27.         swap    d0
  28.        
  29.     ; calculate background scroll  
  30.         move.w  (v_bgscroll_buffer).w,d0
  31.         add.w   (v_bg3screenposx).w,d0
  32.         neg.w   d0
  33.         move.w  #$1F,d1
  34.         sub.w   d4,d1
  35.         bcs.s   @gotoCloud2
  36.     @cloudLoop1:        ; upper cloud (32px)
  37.         move.l  d0,(a1)+
  38.         dbf d1,@cloudLoop1
  39.  
  40.     @gotoCloud2:
  41.         move.w  (v_bgscroll_buffer+4).w,d0
  42.         add.w   (v_bg3screenposx).w,d0
  43.         neg.w   d0
  44.         move.w  #$F,d1
  45.     @cloudLoop2:        ; middle cloud (16px)
  46.         move.l  d0,(a1)+
  47.         dbf d1,@cloudLoop2
  48.  
  49.         move.w  (v_bgscroll_buffer+8).w,d0
  50.         add.w   (v_bg3screenposx).w,d0
  51.         neg.w   d0
  52.         move.w  #$F,d1
  53.     @cloudLoop3:        ; lower cloud (16px)
  54.         move.l  d0,(a1)+
  55.         dbf d1,@cloudLoop3
  56.  
  57.         move.w  #$2F,d1
  58.         move.w  (v_bg3screenposx).w,d0
  59.         neg.w   d0
  60.     @mountainLoop:      ; distant mountains (48px)
  61.         move.l  d0,(a1)+
  62.         dbf d1,@mountainLoop
  63.  
  64.         move.w  #$27,d1
  65.         move.w  (v_bg2screenposx).w,d0
  66.         neg.w   d0
  67.     @hillLoop:          ; hills & waterfalls (40px)
  68.         move.l  d0,(a1)+
  69.         dbf d1,@hillLoop
  70.        
  71.     @scrollFgOnly:
  72.  
  73.         move.w  (v_bg2screenposx).w,d0
  74.         move.w  (v_screenposx).w,d2
  75.         sub.w   d0,d2
  76.         ext.l   d2
  77.         asl.l   #8,d2
  78.         divs.w  #$68,d2
  79.         ext.l   d2
  80.         asl.l   #8,d2
  81.         moveq   #0,d3
  82.         move.w  d0,d3
  83.         move.w  #$47,d1
  84.         add.w   d4,d1
  85.     @waterLoop:         ; water deformation
  86.         ;move.w d3,d0
  87.         neg.w   d0
  88.         move.l  d0,(a1)+
  89.         swap    d3
  90.         add.l   d2,d3
  91.         swap    d3
  92.         dbf d1,@waterLoop
  93.         rts
  94. ; End of function Deform_GHZ
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement