Advertisement
Guest User

tomaitheous

a guest
Mar 5th, 2009
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   ; ((x/8) * map_height)+(y/8)
  2.  
  3.   ; d0=  object #
  4.   ; a1=  X coords array (fixed reg for multiple calls)
  5.   ; a2=  Y coords array (fixed reg for multiple calls)
  6.   ; a3=  shift+mul LUT
  7.   ; a4=  relative starting point of map in circular buffer
  8.   ; d2=  temp
  9.   ; a0=  temp
  10.  
  11.  
  12.  
  13.   moveq     #0,d1             ;4   clear upper reg for building complete address pointer
  14.   moveq     #0,a0             ;4   clear upper range for unsigned indexing
  15.   move.w    0(a1,d0.l),d1     ;14  
  16.   lsl.w     #1,d1             ;8  
  17.   movea.w   d1,a0             ;4   a0=x_array[d0]<<1;
  18.   move.w    0(a2,d0.l),d1     ;14  
  19.   lsr.w     #$03,d1           ;12  d1=y_array[d0]/8;
  20.   add.w     0(a3,a0.l),d1     ;14  d1+=shift_mul_array[a0];
  21.   add.l     a4,d1             ;8   d1+=relative_start_point
  22.   andi.w    #$f7ff,d1         ;8   clip to wrap with buffer
  23.   movea.l   d1,a3             ;4   a3 is now x/y position of map
  24.   addi.w    #col_len,d1       ;8   add a columns worth of bytes to get into the next column
  25.   andi.w    #$f7ff,d1         ;8   clip to wrap with buffer
  26.   movea.l   d2,a4             ;4   a3 is now x/y+1 position of map
  27.   move.w    (a4),d2           ;8
  28.   or.w      (a3),d2           ;8   set Z flag according all four tiles
  29.   rts                         ;16
  30.  
  31.                       ;146 cycles         17 instructions    
  32.  
  33.  
  34.  
  35.  
  36.  
  37.   ; (x>>3 * map_width)+y>>3
  38.   ; _X=  x pixel offset array of objects
  39.   ; _Y=  y pixel offset array of objects
  40.   ; r2=  map column offset
  41.   ; tbl= shift+multiply LUT for column offset
  42.   ; Reg X is the pointer/index to object's positions*
  43.  
  44.   ldy <_Y,x               ;4
  45.   lda shift_lut,y         ;5        y>>3
  46.   ldy <_X,x               ;4
  47.   clc                     ;2
  48.   adc tbl.l,y             ;5
  49.   adc <r2.l               ;4
  50.   sta <r0.l               ;4
  51.   tax                     ;2
  52.   lda tbl.h,y             ;5
  53.   adc <r2.h               ;4
  54.   and #bffr_width         ;2
  55.   sta <r0.h               ;4
  56.   sax                     ;3  
  57.   adc #col_width          ;2
  58.   sta <r1.l               ;4
  59.   txa                     ;2
  60.   adc #$00                ;2
  61.   and #bffr_width         ;2
  62.   sta <r1.h               ;4
  63.   lda [r0]                ;7
  64.   ora [r1]                ;7
  65.   ldy #$01                ;2
  66.   ora [r0],y              ;7
  67.   ora [r1],y              ;7
  68.   rts                     ;7
  69.  
  70.                   ;101 cycles   25 instructions
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.   ldy <_Y,x               ;4
  78.   lda shift_lut,y         ;5  
  79.   lda <_X,x               ;4
  80.   asl a                   ;2
  81.   tay                     ;2
  82.   clc                     ;2
  83.   adc tbl,y               ;5
  84.   adc <r2                 ;4
  85.   and #bffr_width         ;3
  86.   sta <r0                 ;4
  87.   adc #col_width          ;3
  88.   and #bffr_width         ;3
  89.   sta <r1                 ;4
  90.   lda [r0]                ;6
  91.   ora [r1]                ;6
  92.   rts                     ;6
  93.  
  94.                   ;63 cycles   16 instructions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement