ThomasSpeedrunner

Untitled

Aug 7th, 2013
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ===========================================================================
  2. ; ---------------------------------------------------------------------------
  3. ; Subroutine to find which tile the object is standing on
  4. ; d2 = y_pos
  5. ; d3 = x_pos
  6. ; returns relevant block ID in (a1)
  7. ; a1 is pointer to block in chunk table
  8. ; ---------------------------------------------------------------------------
  9.  
  10. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  11.  
  12. ; loc_1E596:
  13. Floor_ChkTile:
  14.     move.w  d2,d0           ; Store y_pos.
  15.     add.w   d0,d0           ; Double it.
  16.     andi.w  #$F00,d0        ; Round the result.
  17.     move.w  d3,d1           ; Store x_pos.
  18.     lsr.w   #3,d1           ; Do something to it.
  19.     move.w  d1,d4           ; Store it again...? Doesn't make sense...
  20.     lsr.w   #4,d1           ; x_pos/128 = x_of_chunk.
  21.     andi.w  #$7F,d1         ; Do a different something to it.
  22.     add.w   d1,d0           ; Add it to d0.
  23.     ; Now, d0 is the relevant chunk ID.
  24.     moveq   #-1,d1          ; Set d1 to the value "$FFFFFFFF".
  25.     clr.w   d1          ; Uhh...clear d1? This doesn't make sense! Anyway, clear a word from d1.
  26.     lea (Level_Layout).w,a1 ; get level layout
  27.     move.b  (a1,d0.w),d1        ; move 128*128 chunk ID to d1
  28.     add.w   d1,d1           ; double it (?)
  29.     move.w  word_1E5D0(pc,d1.w),d1  ; Get the value for the chunk from the table of precalculated ones (huge improvement from S1 in my opinion).
  30.     move.w  d2,d0           ; store y_pos
  31.     andi.w  #$70,d0         ; do something to it
  32.     add.w   d0,d1           ; Add it to d1.
  33.     andi.w  #$E,d4          ; Divide the previously stored x_pos by 8.
  34.     add.w   d4,d1           ; Add it to d1.
  35.     movea.l d1,a1           ; Using d1, get the address of the block ID.
  36.     rts             ; Go back to whatever we were doing before running this routine.
  37. ; ===========================================================================
Advertisement