Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ((x/8) * map_height)+(y/8)
- ; d0= object #
- ; a1= X coords array (fixed reg for multiple calls)
- ; a2= Y coords array (fixed reg for multiple calls)
- ; a3= shift+mul LUT
- ; a4= relative starting point of map in circular buffer
- ; d2= temp
- ; a0= temp
- moveq #0,d1 ;4 clear upper reg for building complete address pointer
- moveq #0,a0 ;4 clear upper range for unsigned indexing
- move.w 0(a1,d0.l),d1 ;14
- lsl.w #1,d1 ;8
- movea.w d1,a0 ;4 a0=x_array[d0]<<1;
- move.w 0(a2,d0.l),d1 ;14
- lsr.w #$03,d1 ;12 d1=y_array[d0]/8;
- add.w 0(a3,a0.l),d1 ;14 d1+=shift_mul_array[a0];
- add.l a4,d1 ;8 d1+=relative_start_point
- andi.w #$f7ff,d1 ;8 clip to wrap with buffer
- movea.l d1,a3 ;4 a3 is now x/y position of map
- addi.w #col_len,d1 ;8 add a columns worth of bytes to get into the next column
- andi.w #$f7ff,d1 ;8 clip to wrap with buffer
- movea.l d2,a4 ;4 a3 is now x/y+1 position of map
- move.w (a4),d2 ;8
- or.w (a3),d2 ;8 set Z flag according all four tiles
- rts ;16
- ;146 cycles 17 instructions
- ; (x>>3 * map_width)+y>>3
- ; _X= x pixel offset array of objects
- ; _Y= y pixel offset array of objects
- ; r2= map column offset
- ; tbl= shift+multiply LUT for column offset
- ; Reg X is the pointer/index to object's positions*
- ldy <_Y,x ;4
- lda shift_lut,y ;5 y>>3
- ldy <_X,x ;4
- clc ;2
- adc tbl.l,y ;5
- adc <r2.l ;4
- sta <r0.l ;4
- tax ;2
- lda tbl.h,y ;5
- adc <r2.h ;4
- and #bffr_width ;2
- sta <r0.h ;4
- sax ;3
- adc #col_width ;2
- sta <r1.l ;4
- txa ;2
- adc #$00 ;2
- and #bffr_width ;2
- sta <r1.h ;4
- lda [r0] ;7
- ora [r1] ;7
- ldy #$01 ;2
- ora [r0],y ;7
- ora [r1],y ;7
- rts ;7
- ;101 cycles 25 instructions
- ldy <_Y,x ;4
- lda shift_lut,y ;5
- lda <_X,x ;4
- asl a ;2
- tay ;2
- clc ;2
- adc tbl,y ;5
- adc <r2 ;4
- and #bffr_width ;3
- sta <r0 ;4
- adc #col_width ;3
- and #bffr_width ;3
- sta <r1 ;4
- lda [r0] ;6
- ora [r1] ;6
- rts ;6
- ;63 cycles 16 instructions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement