; assembly version



lda my ;multiply my by 32

sta ptr_h ;through shifting

ldy #0 ;a 16-bit var (ptr_h,ptr_l)

sty ptr_l ;to the right for three times

dup 3

lsr ptr_h ;shift

ror ptr_l

edup

lda ptr_l ;add mx as 16-bit value

clc

adc mx

bcc @1

inc ptr_h

@1:

clc

adc #<map ;add map offset

sta ptr_l

lda ptr_h

adc #>map

sta ptr_h

lda [ptr_l],y ;read the value



// C version



n=map[(my<<5)+mx];

