home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 41 / af041b.adf / Bullfrogs / draw.s < prev    next >
Text File  |  1992-10-23  |  3KB  |  89 lines

  1.  
  2. ********************************************************************************
  3. *                   oo                              oo                           *
  4. *                 \(  )/      Bullfrog Demo      \(  )/                           *
  5. *                 ^ ^^ ^         Drawing            ^ ^^ ^                           *
  6. ********************************************************************************
  7.  
  8. ;All draw routines in here please.
  9.  
  10. _draw_all
  11.     jsr        _draw_blocks
  12.     move.w    man_x,d0                            ;x position
  13.     asr.w    #FOUR,d0                            ;scale position
  14.     move.w    man_y,d1                            ;y position
  15.     asr.w    #FOUR,d1                            ;scale position
  16.     move.w    man_frame,d2                        ;sprite to draw
  17.     asr.w    #FOUR,d2                            ;slow down animation speed
  18.     lea        _man,a1                                ;gfx data
  19.     jsr        _simple_draw
  20.     rts
  21.  
  22. ********************************************************************************
  23. _draw_blocks
  24. * Therefore a2 points at map data
  25. * d3,d4 is position inside map
  26. * d0,d1 is position on screen
  27.  
  28.     lea        _map_data,a2            ;point a2 at the map data
  29.     move.w    #12-1,d4                ;number of lines -1.
  30.     move.w    #0,d0                    ;start x
  31.     move.w    #0,d1                    ;start y
  32. .loop_y
  33.             move.w    #20-1,d3        ;number of columns -1.
  34. .loop_x
  35.             move.b    (a2)+,d2        ;pick up first byte of data
  36.             beq.s    .next            ;if zero dont draw anything
  37.                 sub.w    #1,d2        ;subtract 1 to get correct block
  38.                 jsr        _block_draw    ;and draw it
  39. .next
  40.             add.w    #1,d0            ;increase x position
  41.         dbra    d3,.loop_x            ;subtract 1 from columns and loop
  42.         move.w    #0,d0                ;move to left side
  43.         add.w    #1,d1                ;and increase y position
  44. ;    dbra    d4,.loop_y                ;sub 1 from rows and loop
  45.     rts    
  46. ********************************************************************************
  47. ;very simple interface for tutorial
  48. ;d0,d1 x,y pos d2 sprite no and a1 points at data
  49.  
  50. _simple_draw
  51.     movem.l    a0-a6/d0-d7,-(sp)
  52.     mulu    #240,d2
  53.     adda.l    d2,a1
  54.     moveq.w    #24,d2                            ;sprite height
  55.     move.l    _w_screen,a0
  56.     jsr        _s16_draw                        ;d0=x,d1=y,d2=height,a0=screen,a1=data
  57.     movem.l    (sp)+,a0-a6/d0-d7
  58.     rts
  59.  
  60. ********************************************************************************
  61. ;very simple blockdraw routine.
  62. ;d0 = x/16, d1 = y/16, d2 = block,
  63.  
  64. _block_draw
  65.     movem.l    a0-a6/d0-d7,-(sp)                ;save all registers
  66.     move.l    _w_screen,a0                    ;point at screen
  67.     lea        _blocks,a1                        ;point at block data
  68.     asl.w    #TWO,d0                            ;find x position on screen
  69.     asl.w    #SIXTEEN,d1                        ;find y position on screen
  70.     mulu    #SCREEN_WIDTH,d1                ;move down that no. of lines
  71.     adda.l    d1,a0                            ;point at y
  72.     adda.l    d0,a0                            ;point at x
  73.     mulu    #128,d2                            ;find start of block to draw
  74.     adda.l    d2,a1                            ;and move to it.
  75.     moveq.w    #16-1,d2                        ;sprite height
  76.  
  77. .loop
  78.         movem.w    (a1)+,d3/d4/d5/d6            ;pick up all data
  79.         move.w    d3,(a0)                        ;plane one
  80.         move.w    d4,PLANE_SIZE(a0)            ;plane two
  81.         move.w    d5,PLANE_SIZE*2(a0)            ;plane three
  82.         move.w    d6,PLANE_SIZE*3(a0)            ;plane four
  83.         lea        SCREEN_WIDTH(a0),a0            ;move to next line
  84.     dbra    d2,.loop                        ;loop around 16 times
  85.     movem.l    (sp)+,a0-a6/d0-d7                ;restore all registers
  86.     rts
  87.  
  88. ********************************************************************************
  89.