home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / JAGDEV_1.LZH / DEVELOP.JAG / VECTRONI.X! / 3DDEMO / GPU.S < prev    next >
Text File  |  1994-11-12  |  4KB  |  143 lines

  1. ;*======================================================================*
  2. ;*                TITLE:                  GPU.S                         *
  3. ;*                Function:               Gpu interfece routines        *
  4. ;*                                                                      *
  5. ;*                Project #:              RAPIER                        *
  6. ;*                Programmer:             Andrew J Burgess              *
  7. ;*                                        Rob Zdybel                    *
  8. ;*                                                                      *
  9. ;*              COPYRIGHT 1992/1993 Atari Computer Corporation          *
  10. ;*          UNATHORIZED REPRODUCTION, ADAPTATION, DISTRIBUTION,         *
  11. ;*          PERFORMANCE OR DISPLAY OF THIS COMPUTER PROGRAM OR          *
  12. ;*        THE ASSOCIATED AUDIOVISUAL WORK IS STRICTLY PROHIBITED.       *
  13. ;*                            ALL RIGHTS RESERVED.                      *
  14. ;*                                                                      *
  15. ;*======================================================================*
  16.  
  17.     include "jaguar.inc"
  18.     include "joytrick.inc"
  19.  
  20. ;
  21. ;    PUBLIC SYMBOLS
  22. ;
  23.     .globl    gpuload
  24.     .globl    gpurun
  25.     .globl    gpuwait
  26.  
  27.     .extern    framecnt
  28.  
  29. ;*======================================================================*
  30. ;* gpuload()    - load a GPU program into GPU RAM
  31. ;*
  32. ;*    input:
  33. ;*        a0    - 68000 address of GPU program
  34. ;*        a1    - destination address
  35. ;*        d0    - size of program
  36. ;*
  37. ;*    preserved:
  38. ;*        d0-d1
  39. ;*        a0-a1
  40. ;*======================================================================*
  41. gpuload:
  42.     movem.l    d0-d1/a0-a2,-(sp)        ; save GPU address for restore
  43.  
  44.     move.l    #B_CMD,a2
  45. .waitblit:            ; Wait for BLTTER Idle
  46.     move.l    (a2),d1
  47.     lsr.w    #1,d1
  48.     bcc    .waitblit
  49.  
  50.     jsr    gpuwait
  51.  
  52.     ; This code will load a gpu program into the Blitter at the address
  53.     ; specified in the header 
  54.  
  55.     move.l    #PITCH1|PIXEL16|WID256|XADDPHR,d1
  56.     move.l    d1,A1_FLAGS
  57.     move.l    d1,A2_FLAGS
  58.     
  59.     ; Point A1BASE to the destination
  60.  
  61.     move.l    a1,A1_BASE
  62.  
  63.     ; Set the pixel pointer to the offset in d1
  64.  
  65.     move.l    #0,A1_PIXEL
  66.  
  67.     ; Find size of data to load
  68.  
  69.     asr.l    #1,d0        ; Convert to words
  70.     or.l    #$10000,d0    ; Set 1 outer loop
  71.     move.l    d0,B_COUNT
  72.  
  73.     ; Set up Counters register to number of words
  74.  
  75.     ; Point A2BASE to the source
  76.     ; a0 now points to the data
  77.  
  78.     move.l    a0,A2_BASE
  79.  
  80.     ; Set the pixel pointer to the offset in d1
  81.  
  82.     move.l    #0,A2_PIXEL
  83.  
  84.     move.l    #SRCEN|LFU_AN|LFU_A,d0
  85. .blit_go:
  86.     move.l    d0,B_CMD
  87. ;
  88. ;    NOTE: No Wait for BLTTER Idle - I have yet to be overrun but WARNING
  89. ;
  90.     movem.l    (sp)+,d0-d1/a0-a2
  91.     rts
  92.  
  93. ;*======================================================================*
  94. ;* gpurun()    - tell the GPU to begin execution
  95. ;*
  96. ;*    input:
  97. ;*        a0    - 68000 address of GPU program
  98. ;*
  99. ;*    preserved:
  100. ;*        d0-d1
  101. ;*        a0
  102. ;*======================================================================*
  103. gpurun:
  104.     movem.l    d0-d1/a0,-(sp)        ; save GPU address for restore
  105.     move.l    #$F03000,G_PC
  106.  
  107.     move.l    #$11,G_CTRL        ; Turn on the GPU
  108.  
  109.     movem.l    (sp)+,a0/d0-d1        ; restore GPU address
  110.     rts
  111.  
  112. ;*======================================================================*
  113. ;* gpuwait()    - wait for the GPU to finish executing
  114. ;*
  115. ;*    input:
  116. ;*        None
  117. ;*
  118. ;*    preserved:
  119. ;*        d0
  120. ;*        a0
  121. ;*======================================================================*
  122. gpuwait:
  123.     movem.l    a0-a1/d0-d1,-(sp)
  124.  
  125.     lea    G_CTRL,a0
  126.     move.l    #$400000,a1
  127. .gpuwt:                ; wait for GPU to finish
  128.     move.l    framecnt,d1
  129.     swap    d1
  130.     move.w    $f00006,d1
  131.     move.l    d1,(a1)+
  132.     move.l    #-1,(a1)
  133.     move.l    (a0),d0
  134.     asr    #1,d0
  135.     bcs    .gpuwt
  136.  
  137.     movem.l    (sp)+,a0-a1/d0-d1
  138.     rts
  139. ;*======================================================================*
  140. ;*                                 EOF                                  *
  141. ;*======================================================================*
  142.  
  143.