| Assembly Source File | Created 12/12/2006 09:22:59 PM .xdef ClipGrayDrawTilemap16_fast .xdef ClipGraySprite16_MASK ClipGrayDrawTilemap16_fast: |short x asm("%d0"), short y asm("%d1"), TILEMAP *tilemap asm("%a0"), void *light asm("%a1"), void *dark asm("%a2") movem.l %d3-%d7/%a2-%a6,-(%sp) |save registers move.w %d0,%d2 move.w %d1,%d3 lsr.w #4,%d2 |index_x lsr.w #4,%d3 |index_y and.w #15,%d0 neg %d0 |-(x&15) and.w #15,%d1 neg %d1 |-(y&15) |%d0 and %d1 now hold -(x&15) and -(y&15) respectively, since we no longer need x and y movea %a0,%a3 |location of tilemap->map muls.w 12(%a0),%d3 |start_index_y=tilemap->width*index_y; adda %d3,%a3 adda %d2,%a3 |%a3 now has the starting index for the first drawn tile of the tilemap move.w #0,%d2 |%d2 is our vertical loop var (i) move.w #0,%d3 |%d3 is loop_w move.w #0,%d4 |%d4 is loop_v horizontal: |draw_x=-(x&15)+(loop_w<<4); move.w %d3,%d5 lsl #4,%d5 add.w %d0,%d5 |%d5=draw_x move.w %d2,%d5 add.w %d1,%d6 |%d6=draw_y |matrix_offset=*(map+start_index_y+index_x+loop_v+loop_w); movea %a3,%a4 adda %d3,%a4 adda %d4,%a4 |address of matrix_offset move.w (%a4),%d7 |%d6 now holds matrix_offset /*___Prepare the sprite function___*/ move.l %a2,-(%sp) |void *dark move.l %a1,-(%sp) |void *light lsl.w #4,%d7 |matrix_offset<<4 lea 8(%a0),%a5 |%a5 points to tilemap->masks adda %d7,%a5 move.l %a2,-(%sp) |masks+(matrix_offset<<4) move.w (%a4),%d7 |%d7 now holds matrix_offset lsl.w #5,%d7 add.w #16,%d7 lea 4(%a0),%a5 adda %d7,%a5 move.l %a5,-(%sp) |sprts+(matrix_offset<<5)+16 suba #16,%a5 move.l %a5,-(%sp) |sprts+(matrix_offset<<5) move.w #16,-(%sp) move.w %d6,-(%sp) move.w %d5,-(%sp) |save registers that will be trashed by the routine movem.l %d0-%d2/%a0-%a1,-(%sp) jbsr ClipGraySprite16_MASK |draw the tile movem.l (%sp)+,%d0-%d2/%a0-%a1 |restore registers lea 26(%sp),%sp |restore stack pointer |increment loop vars and test for jumping addq #1,%d3 cmpi.w #11,%d3 blt horizontal add.w #16,%d2 add.w 12(%a0),%d4 cmpi.w #8*16,%d2 blt horizontal movem.l (%sp)+,%d3-%d7/%a2-%a6 |save registers rts