home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 39 / af039a.adf / display.s < prev    next >
Text File  |  1992-09-17  |  3KB  |  139 lines

  1. FUNC_DISPLAY    =    1
  2. FUNC_MUSIC        =    0
  3. PLANESIZE    =    SCREEN_WIDTH*SCREEN_HEIGHT
  4. ******************************************************************************
  5.     xdef    _display
  6. _display
  7.     movem.l    d0-d7/a0-a6,-(sp)
  8.     jsr        _set_up_disc
  9. .repeat
  10.  
  11.     jsr        _wait_vbi                ; wait for a vertical blank
  12.     jsr        _clear_screen
  13.  
  14. ;    move.w    #$707,(COLOR).l
  15.     jsr        _draw_all                ; draw all the sprites and things
  16.  
  17.     jsr        _swap_screens            ; display the screen
  18.  
  19.     jsr        _move_all                ; move all the sprites and things
  20.  
  21.     cmp.b    #KB_Q,_iinkey            ; have we pressed the quit key?
  22.     bne        .repeat                    ; no then loop around
  23. .the_end                            ; Oh we have then lets exit
  24.     movem.l    (sp)+,d0-d7/a0-a6
  25.     rts
  26.     even
  27.     dc.l    0,0    
  28. **************************************************************************
  29. _lmul                                ; long multiply routine
  30.     movem.l    d1-d3,-(sp)
  31.     move.w    d0,d2
  32.     move.w    d1,d3
  33.     swap    d0
  34.     swap    d1
  35.     mulu    d2,d1
  36.     mulu    d3,d0
  37.     mulu    d3,d2
  38.     add.w    d1,d0
  39.     swap    d0
  40.     clr.w    d0
  41.     add.l    d2,d0
  42.     movem.l    (sp)+,d1-d3
  43.     rts
  44. ******************************************************************************
  45. *                        Random Number Routine                                 *
  46. ******************************************************************************
  47.  
  48. _rnd                                        ;takes d1 (0-d1)
  49.     move.w    .seed(pc),d0
  50.     mulu    #9377,d0
  51.     add.w    #9439,d0
  52.     move.w    d0,.seed
  53.     and.l    #$7fff,d0                        ;make sure positive word
  54.  
  55.     divu    d1,d0
  56.     swap    d0
  57.     rts
  58. .seed    dc.w    1972
  59. ******************************************************************************
  60. _abs                        ; turn number to absolute
  61.     tst.w    d0
  62.     bpl.s    .positive
  63.         neg.w    d0
  64. .positive
  65.     rts
  66. ******************************************************************************
  67. *                        Redraw a Background Screen                             *
  68. ******************************************************************************
  69.  
  70. _q_redraw            ;needs a0 as data to copy
  71.     move.l    _w_screen,a1
  72.     move.l    #32000/40/4-1,d7
  73. .copy_loop
  74.     movem.l    (a0)+,a2-a4/d0-d6
  75.     movem.l    a2-a4/d0-d6,(a1)
  76.     lea        40(a1),a1
  77.     movem.l    (a0)+,a2-a4/d0-d6
  78.     movem.l    a2-a4/d0-d6,(a1)
  79.     lea        40(a1),a1
  80.     movem.l    (a0)+,a2-a4/d0-d6
  81.     movem.l    a2-a4/d0-d6,(a1)
  82.     lea        40(a1),a1
  83.     movem.l    (a0)+,a2-a4/d0-d6
  84.     movem.l    a2-a4/d0-d6,(a1)
  85.     lea        40(a1),a1
  86.     dbra    d7,.copy_loop
  87.     rts
  88.  
  89. ******************************************************************************
  90. _clear_all_registers
  91.     moveq.l    #0,d0
  92.     moveq.l    #0,d1
  93.     moveq.l    #0,d2
  94.     moveq.l    #0,d3
  95.     moveq.l    #0,d4
  96.     moveq.l    #0,d5
  97.     moveq.l    #0,d6
  98.     moveq.l    #0,d7
  99.     move.l    d0,a0
  100.     move.l    d0,a1
  101.     move.l    d0,a2
  102.     move.l    d0,a3
  103.     move.l    d0,a4
  104.     move.l    d0,a5
  105.     move.l    d0,a6
  106.     rts
  107.  
  108. ******************************************************************************
  109. quit                    dc.w    0
  110.  
  111. _sp_screen                                ;where sprites can be drawn
  112.     dc.l    0
  113.  
  114.  
  115. title
  116. backscreen
  117.      ds.b    32000
  118.     even
  119.  
  120. an1    dc.l    0,0,0                            ;animation stack
  121. ******************************************************************************
  122. * uses d0 as counter, a0 as screen
  123. _clear_screen
  124.     bsr        _clear_all_registers        ; clear all registers
  125.     move.l    _w_screen,a0                ; find start of screen to clear
  126.     lea        32000(a0),a0                ; and move to the end of it
  127.     moveq.w    #(615/5)-1,d0                ; number of times we want to loop -1
  128. .loop
  129.     movem.l    d1-d7/a1-a6,-(a0)            ; clear 52 bytes
  130.     movem.l    d1-d7/a1-a6,-(a0)            ; 5 times
  131.     movem.l    d1-d7/a1-a6,-(a0) 
  132.     movem.l    d1-d7/a1-a6,-(a0)
  133.     movem.l    d1-d7/a1-a6,-(a0)
  134.     dbra    d0,.loop
  135.     movem.l    d1-d5,-(a0)                    ;clear off the last 20 bytes
  136.     rts
  137.     
  138.     
  139.