Prev: 7BE4 Up: Map Next: 7C26
7BF2: Calculate interior item isometric position
This calculates the isometric screen position for the given interior item. Unlike the exterior version of this routine at calc_exterior_item_iso_pos, this version scales the result down with rounding to nearest.
Used by the routine at item_discovered.
Input
HL Pointer to itemstruct's pos.height field.
Set A' to ($200 + y - x) * 2
calc_interior_item_iso_pos 7BF2 DEC HL Step HL back to itemstruct.pos.y
7BF3 LD D,$02 Start with $200 + pos.y
7BF5 LD E,(HL)
7BF6 EX DE,HL Use via DE now
7BF7 DEC DE Step DE back to pos.x
7BF8 LD A,(DE) Fetch pos.x
7BF9 LD C,A Widen it to 16-bit
7BFA LD B,$00
7BFC AND A Clear carry flag
7BFD SBC HL,BC Subtract (widened) pos.x
7BFF ADD HL,HL Double the result
7C00 LD C,H Move result into (C,A)
7C01 LD A,L
7C02 CALL divide_by_8_with_rounding Divide by 8 with rounding. Result is in A
7C05 EX AF,AF' Bank x result
Set A to ($800 - x - y - height)
7C06 LD HL,$0800 Start with $800
7C09 LD B,$00 Load and widen pos.x to 16-bit
7C0B LD A,(DE)
7C0C LD C,A
7C0D AND A Clear carry flag
7C0E SBC HL,BC Subtract (widened) pos.x
7C10 INC DE Advance DE to pos.y
7C11 LD A,(DE) Load and widen pos.y to 16-bit (B already zero)
7C12 LD C,A
7C13 SBC HL,BC Subtract (widened) pos.y
7C15 INC DE Advance DE to pos.height
7C16 LD A,(DE) Load and widen pos.height to 16-bit (B already zero)
7C17 LD C,A
7C18 SBC HL,BC Subtract (widened) pos.height
7C1A LD C,H Move result into (C,A)
7C1B LD A,L
7C1C CALL divide_by_8_with_rounding Divide by 8 with rounding. Result is in A
Write the result to itemstruct.iso_pos
7C1F INC DE Advance DE to itemstruct.iso_pos
7C20 INC DE
7C21 LD (DE),A Store A (y result)
7C22 DEC DE
7C23 EX AF,AF' Unbank x result
7C24 LD (DE),A Store A (x result)
7C25 RET Return
Prev: 7BE4 Up: Map Next: 7C26