home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_03 / SOURCE_J.LZH / 3DDEMO / OBJLIST.S < prev    next >
Text File  |  1994-09-08  |  7KB  |  244 lines

  1. ;*======================================================================*
  2. ;*                TITLE:                  OBJLIST.S                     *
  3. ;*                Function:               Object List Driver            *
  4. ;*                                                                      *
  5. ;*                Project #:              JAGUAR                        *
  6. ;*                Programmer:             Eric Ginner                   *
  7. ;*                                        Andrew J Burgess              *
  8. ;*                                                                      *
  9. ;*              COPYRIGHT 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.  
  18.        include  "jaguar.inc"
  19.        include "3ddemo.inc"
  20.  
  21. ;*======================================================================*
  22. ;*      EXTERNAL SYMBOLS
  23. ;*======================================================================*
  24.  
  25.     .extern a_vdb
  26.     .extern a_vde
  27.     .extern height
  28.     .extern width
  29.     .extern DISPBUF0
  30.  
  31. ;*======================================================================*
  32. ;*      EXTERNAL ROUTINES
  33. ;*======================================================================*
  34.  
  35.  
  36. ;*======================================================================*
  37. ;*      PUBLIC SYMBOLS
  38. ;*======================================================================*
  39.  
  40.     .globl  bmp_data
  41.     .globl  objlist
  42.  
  43. ;*======================================================================*
  44. ;*      PUBLIC ROUTINES
  45. ;*======================================================================*
  46.  
  47.     .globl  InitLister
  48.     .globl  UpdateList
  49.  
  50. ;*======================================================================*
  51. ;*      PROGRAM SEGMENT
  52. ;*======================================================================*
  53.     
  54.     .text
  55.  
  56. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  57. ; InitLister: Initialize Object List Processor List
  58. ;
  59. ;    Returns: Pre-word-swapped address of current object list in d0.l
  60. ;
  61. ;  Registers: d1.l/d0.l - Phrase being built
  62. ;             d2.l      - Address of STOP object in destination buffer
  63. ;             d3.l      - Calculation register
  64. ;             d4.l      - Width of image in phrases
  65. ;             d5.l      - Height of image in scanlines
  66. ;             a0.l      - Roving object list pointer
  67.         
  68. InitLister:
  69.         movem.l d1-d5/a0,-(sp)          ; Save registers
  70.             
  71.         lea     objlist,a0
  72.         move.l  a0,d2                   ; Copy
  73.  
  74.         add.l   #(LISTSIZE-1)*8,d2      ; Address of STOP object
  75.  
  76. ; Write first BRANCH object (branch if YPOS > a_vde )
  77.  
  78.         clr.l   d1
  79.         move.l  #(BRANCHOBJ|O_BRLT),d0  ; $4000 = VC < YPOS
  80.         jsr     format_link             ; Stuff in our LINK address
  81.                         
  82.         move.w  a_vde,d3                ; for YPOS
  83.         lsl.w   #3,d3                   ; Make it bits 13-3
  84.         or.w    d3,d0
  85.  
  86.         move.l  d1,(a0)+                                
  87.         move.l  d0,(a0)+                ; First OBJ is done.
  88.  
  89. ; Write second branch object (branch if YPOS < a_vdb)   
  90. ; Note: LINK address is the same so preserve it
  91.  
  92.         andi.l  #$FF000007,d0           ; Mask off CC and YPOS
  93.         ori.l   #O_BRGT,d0              ; $8000 = VC > YPOS
  94.         move.w  a_vdb,d3                ; for YPOS
  95.         lsl.w   #3,d3                   ; Make it bits 13-3
  96.         or.w    d3,d0
  97.  
  98.         move.l  d1,(a0)+                ; Second OBJ is done
  99.         move.l  d0,(a0)+        
  100.  
  101. ; Write a standard BITMAP object
  102.         clr.l   d1
  103.         clr.l   d0                      ; Type = BITOBJ
  104.             
  105.         jsr     format_link
  106.  
  107.         move.l  #BMP_HEIGHT,d5          ; Height of image
  108.         move.w  d5,bmp_height           ; Store for later update
  109.  
  110.         lsl.l   #8,d5                   ; HEIGHT
  111.         lsl.l   #6,d5
  112.         or.l    d5,d0
  113.  
  114.         move.w  height,d3               ; Center bitmap vertically
  115.         sub.w   #BMP_HEIGHT,d3
  116.         add.w   a_vdb,d3
  117.         andi.w  #$FFFE,d3               ; Must be even
  118.  
  119.         lsl.w   #3,d3
  120.         or.w    d3,d0                   ; Stuff YPOS in low phrase
  121.  
  122.         move.l  #DISPBUF0,d3
  123.         andi.l  #$FFFFF0,d3
  124.         lsl.l   #8,d3                   ; Shift bitmap_addr into position
  125.         or.l    d3,d1
  126.  
  127.         move.l  #DISPBUF0,bmp_data      ; Initialize
  128.      
  129.         move.l  d1,(a0)+
  130.         move.l  d1,bmp_highl
  131.         move.l  d0,(a0)+
  132.         move.l  d0,bmp_lowl
  133.  
  134.         clr.l   d1
  135.         move.l  #O_TRANS,d1             ; Now for PHRASE 2 of BITOBJ
  136.         move.l  #O_DEPTH16|O_1GAP,d0    ; Bit Depth = 16-bit 
  137.  
  138.         clr.l   d3                      ; Determine screen width
  139.         move.w  width,d3
  140.         divu    #3,d3
  141. ;               lsr.w   #2,d3                   ; /4 Pixel Divisor
  142.         sub.w   #BMP_WIDTH,d3
  143.         lsr.w   #1,d3
  144.         or.w    d3,d0
  145.  
  146.         move.l  #BMP_PHRASES,d4 
  147.         move.l  #BMP_CLIP,d3
  148.  
  149.         lsl.l   #8,d4                   ; DWIDTH
  150.         lsl.l   #8,d4
  151.         lsl.l   #2,d4
  152.         or.l    d4,d0
  153.  
  154.         lsl.l   #8,d4                   ; IWIDTH Bits 28-31
  155.         lsl.l   #2,d4
  156.         or.l    d4,d0
  157.  
  158.         lsr.l   #4,d3                   ; IWIDTH Bits 37-32
  159.         or.l    d3,d1
  160.  
  161.         move.l  d1,(a0)+                ; Write second PHRASE of BITOBJ
  162.         move.l  d0,(a0)+
  163.  
  164. ; Write a STOP object at end of list
  165.         clr.l   d1
  166.         move.l  #(STOPOBJ|O_STOPINTS),d0
  167.  
  168.         move.l  d1,(a0)+                
  169.         move.l  d0,(a0)+
  170.  
  171.         movem.l (sp)+,d1-d5/a0
  172.         rts
  173.  
  174. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  175. ; Procedure: format_link
  176. ;
  177. ;    Inputs: d1.l/d0.l is a 64-bit phrase
  178. ;            d2.l contains the LINK address to put into bits 42-24 of phrase
  179. ;
  180. ;   Returns: Updated phrase in d1.l/d0.l
  181.  
  182. format_link:
  183.         movem.l d2-d3,-(sp)
  184.  
  185.         andi.l  #$3FFFF8,d2             ; Ensure alignment/valid address
  186.         move.l  d2,d3                   ; Make a copy
  187.  
  188.         swap    d2                      ; Put bits 10-3 in bits 31-24
  189.         clr.w   d2
  190.         lsl.l   #5,d2
  191.         or.l    d2,d0
  192.  
  193.         lsr.l   #8,d3                   ; Put bits 21-11 in bits 42-32
  194.         lsr.l   #3,d3
  195.         or.l    d3,d1
  196.  
  197.         movem.l (sp)+,d2-d3             ; Restore regs
  198.         rts
  199.  
  200. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  201. ; UpdateList: Update list fields destroyed by the object processor.
  202. ;
  203. ;  Registers:   a0.l      - General Purpose Pointer
  204.  
  205. UpdateList:
  206.         movem.l a0/d0-d1,-(sp)
  207.  
  208.         move.l  #objlist+BITMAP_OFF,a0
  209.  
  210.         move.l  bmp_highl,d1
  211.         andi.l  #$7FF,d1                ; Mask off old DATA
  212.         move.l  bmp_data,d0             ; Get current picture data
  213.         lsl.l   #8,d0                   ; Format ptr and store
  214.         or.l    d0,d1
  215.         move.l  d1,(a0)
  216.            
  217.         move.l  bmp_lowl,4(a0)
  218.  
  219.         movem.l (sp)+,a0/d0-d1
  220.         rts
  221.  
  222. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  223. ;;;; Storage space for our object lists
  224.  
  225.         .bss
  226.         .dphrase                        
  227.  
  228. objlist:
  229.         .ds.l   (2*LISTSIZE)
  230. bmp_height:
  231.         .ds.w   1
  232. bmp_highl:
  233.         .ds.l   1
  234. bmp_lowl:
  235.         .ds.l   1
  236. bmp_data:
  237.         .ds.l   1
  238.  
  239.         .end
  240.  
  241. ;*======================================================================*
  242. ;*                              EOF
  243. ;*======================================================================*
  244.