; ===========================================================================
; ---------------------------------------------------------------------------
; Subroutine to find which tile the object is standing on
; d2 = y_pos
; d3 = x_pos
; returns relevant block ID in (a1)
; a1 is pointer to block in chunk table
; ---------------------------------------------------------------------------
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
; loc_1E596:
Floor_ChkTile:
move.w d2,d0 ; Store y_pos.
add.w d0,d0 ; Double it.
andi.w #$F00,d0 ; Round the result.
move.w d3,d1 ; Store x_pos.
lsr.w #3,d1 ; Do something to it.
move.w d1,d4 ; Store it again...? Doesn't make sense...
lsr.w #4,d1 ; x_pos/128 = x_of_chunk.
andi.w #$7F,d1 ; Do a different something to it.
add.w d1,d0 ; Add it to d0.
; Now, d0 is the relevant chunk ID.
moveq #-1,d1 ; Set d1 to the value "$FFFFFFFF".
clr.w d1 ; Uhh...clear d1? This doesn't make sense! Anyway, clear a word from d1.
lea (Level_Layout).w,a1 ; Get the address of the level layout.
move.b (a1,d0.w),d1 ; Move the 128*128 chunk ID to d1.
add.w d1,d1 ; Double it.
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).
move.w d2,d0 ; Store y_pos.
andi.w #$70,d0 ; Do something to it.
add.w d0,d1 ; Add it to d1.
andi.w #$E,d4 ; Divide the previously stored x_pos by 8.
add.w d4,d1 ; Add it to d1.
movea.l d1,a1 ; Using d1, get the address of the block ID.
rts ; Go back to whatever we were doing before running this routine.
; ===========================================================================
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎