home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 43 / af043a.adf / BULL6.LHA / draw.s < prev    next >
Text File  |  1992-12-15  |  6KB  |  220 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.     jsr        _draw_collectables
  13.     jsr        _draw_bad_guys
  14.     jsr        _draw_score
  15.     jsr        _lives_left
  16. ;    jsr        _draw_logo
  17.     move.w    man_x,d0                            ;x position
  18.     asr.w    #FOUR,d0                            ;scale position
  19.     move.w    man_y,d1                            ;y position
  20.     asr.w    #FOUR,d1                            ;scale position
  21.     move.w    man_frame,d2                        ;sprite to draw
  22.     asr.w    #FOUR,d2                            ;slow down animation speed
  23.     lea        _man,a1                                ;gfx data
  24.     jsr        _simple_draw
  25.     rts
  26.  
  27. ********************************************************************************
  28. _draw_blocks
  29. * Therefore a2 points at map data
  30. * d3,d4 is position inside map
  31. * d0,d1 is position on screen
  32.  
  33.     move.l    map_pointer,a2            ;point a2 at the map data
  34.     move.w    #12-1,d4                ;number of lines -1.
  35.     move.w    #0,d0                    ;start x
  36.     move.w    #0,d1                    ;start y
  37. .loop_y
  38.             move.w    #20-1,d3        ;number of columns -1.
  39. .loop_x
  40.             move.b    (a2)+,d2        ;pick up first byte of data
  41.             beq.s    .next            ;if zero dont draw anything
  42.                 sub.w    #1,d2        ;subtract 1 to get correct block
  43.                 jsr        _block_draw    ;and draw it
  44. .next
  45.             add.w    #1,d0            ;increase x position
  46.         dbra    d3,.loop_x            ;subtract 1 from columns and loop
  47.         move.w    #0,d0                ;move to left side
  48.         add.w    #1,d1                ;and increase y position
  49.     dbra    d4,.loop_y                ;sub 1 from rows and loop
  50.     rts    
  51. ********************************************************************************
  52. ;very simple interface for tutorial
  53. ;d0,d1 x,y pos d2 sprite no and a1 points at data
  54.  
  55. _simple_draw
  56.     movem.l    a0-a6/d0-d7,-(sp)
  57.     mulu    #240,d2
  58.     adda.l    d2,a1
  59.     moveq.w    #24,d2                            ;sprite height
  60.     move.l    _w_screen,a0
  61.     jsr        _s16_draw                        ;d0=x,d1=y,d2=height,a0=screen,a1=data
  62.     movem.l    (sp)+,a0-a6/d0-d7
  63.     rts
  64.  
  65. ********************************************************************************
  66. ;very simple blockdraw routine.
  67. ;d0 = x/16, d1 = y/16, d2 = block,
  68.  
  69. _block_draw
  70.     movem.l    a0-a6/d0-d7,-(sp)                ;save all registers
  71.     move.l    _w_screen,a0                    ;point at screen
  72.     lea        _blocks,a1                        ;point at block data
  73.     asl.w    #TWO,d0                            ;find x position on screen
  74.     asl.w    #SIXTEEN,d1                        ;find y position on screen
  75.     mulu    #SCREEN_WIDTH,d1                ;move down that no. of lines
  76.     adda.l    d1,a0                            ;point at y
  77.     adda.l    d0,a0                            ;point at x
  78.     mulu    #128,d2                            ;find start of block to draw
  79.     adda.l    d2,a1                            ;and move to it.
  80.     moveq.w    #16-1,d2                        ;sprite height
  81.  
  82. .loop
  83.         movem.w    (a1)+,d3/d4/d5/d6            ;pick up all data
  84.         move.w    d3,d7
  85.         or.w    d4,d7
  86.         or.w    d5,d7
  87.         or.w    d6,d7
  88.         not.w    d7
  89.  
  90.         and.w    d7,(a0)
  91.         or.w    d3,(a0)                        ;plane one
  92.         and.w    d7,PLANE_SIZE(a0)
  93.         or.w    d4,PLANE_SIZE(a0)            ;plane two
  94.         and.w    d7,PLANE_SIZE*2(a0)
  95.         or.w    d5,PLANE_SIZE*2(a0)            ;plane three
  96.         and.w    d7,PLANE_SIZE*2(a0)
  97.         or.w    d6,PLANE_SIZE*3(a0)            ;plane four
  98.         lea        SCREEN_WIDTH(a0),a0            ;move to next line
  99.     dbra    d2,.loop                        ;loop around 16 times
  100.     movem.l    (sp)+,a0-a6/d0-d7                ;restore all registers
  101.     rts
  102.  
  103. ********************************************************************************
  104.  
  105. _draw_collectables
  106.     lea        _objects,a2
  107.     move.w    #MAX_OBJECTS-1,d7
  108.  
  109. .loop
  110.     tst.w    OBJ_ON(a2)
  111.     beq.s    .next
  112.         movem.w    OBJ_TO_DRAW(a2),d0/d1/d2
  113.         move.l    _w_screen,a0
  114.         lea        _collect,a1
  115.         mulu    #SCREEN_WIDTH,d1
  116.         adda.w    d1,a0
  117.         asr.w    #EIGHT,d0
  118.         adda.w    d0,a0
  119.         mulu    #128,d2
  120.         adda.w    d2,a1
  121.         move.w    #16-1,d0
  122. ;        move.l    _w_screen,a0
  123. ;        lea        _collect,a1
  124. .draw_loop
  125.             movem.w    (a1)+,d1/d2/d3/d4
  126.             move.w    d1,(a0)
  127.             move.w    d2,PLANE_SIZE(a0)
  128.             move.w    d3,PLANE_SIZE*2(a0)
  129.             move.w    d4,PLANE_SIZE*3(a0)
  130.             lea        SCREEN_WIDTH(a0),a0
  131.         dbra    d0,.draw_loop
  132. .next
  133.     lea        OBJ_SIZE(a2),a2
  134.     dbra    d7,.loop
  135.     rts
  136. ********************************************************************************
  137. _draw_score
  138.     lea        _score_text,a0
  139.     move.l    #0,d0
  140.     move.w    score,d0
  141. ;    ext.l    d0
  142.     move.w    #5,d1
  143.     adda.l    #7,a0
  144.     jsr        _to_alpha
  145.  
  146.     move.w    #1,d0
  147.     move.w    #192,d1
  148.     lea        _score_text,a2
  149.     jsr        _draw_font
  150.     rts
  151. ********************************************************************************
  152. *pass x block, pixal perfect y, a2 points to text to print
  153. _draw_font
  154.     mulu    #SCREEN_WIDTH,d1
  155. .begin
  156.     move.b    (a2)+,d2                ;look at letter
  157.     beq.s    .finished
  158.     cmp.b    #32,d2
  159.     beq.s    .next
  160.         ext.w    d2
  161.         sub.w    #33,d2
  162.         lea        _font,a1
  163.         asl.w    #EIGHT,d2
  164.         adda.w    d2,a1
  165.  
  166.         move.l    _w_screen,a0
  167.         adda.w    d1,a0
  168.         adda.w    d0,a0
  169.  
  170.         move.w    #8-1,d3
  171. .draw_loop
  172.             move.b    (a1)+,(a0)
  173.             lea        SCREEN_WIDTH(a0),a0
  174.         dbra    d3,.draw_loop
  175. .next
  176.     add.w    #1,d0
  177.     bra.s    .begin
  178. .finished
  179.     rts
  180. ********************************************************************************
  181. _draw_bad_guys
  182.     lea        _bad_guys,a0
  183.     moveq.w    #MAX_BADDIES,d3
  184. .loop
  185.     tst.w    BAD_ON(a0)
  186.     beq.s    .next
  187.         movem.w    BAD_TO_DRAW(a0),d0/d1/d2
  188.         movem.l    a0-a6/d0-d7,-(sp)
  189.         lea        _bad,a1
  190.         mulu    #160,d2
  191.         adda.l    d2,a1
  192.         moveq.w    #16,d2                            ;sprite height
  193.         move.l    _w_screen,a0
  194.         jsr        _s16_draw                        ;d0=x,d1=y,d2=height,a0=screen,a1=data
  195.         movem.l    (sp)+,a0-a6/d0-d7
  196. .next
  197.     lea        BAD_SIZE(a0),a0
  198.     dbra    d3,.loop
  199.     rts
  200.  
  201. ********************************************************************************
  202.  
  203. _lives_left
  204.     move.w    #272,d0                                ;x position
  205.     move.w    #176,d1                                ;y position
  206.     move.w    #MAN_STATIONARY,d2                    ;sprite to draw
  207.     asr.w    #FOUR,d2
  208.     lea        _man,a1                                ;gfx data
  209.     move.w    #1,d3
  210.     sub.w    game_over,d3
  211.     blt.s    .nothing_to_draw
  212. .loop
  213.     jsr        _simple_draw
  214.     add.w    #16,d0
  215.     dbra    d3,.loop
  216. .nothing_to_draw
  217.     rts
  218. ********************************************************************************
  219.  
  220.