home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17510 < prev    next >
Encoding:
Internet Message Format  |  1992-12-20  |  6.4 KB

  1. Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!altair88!jdresser
  2. From: jdresser@altair88.UUCP (Jay Dresser)
  3. Message-ID: <jdresser.2252@altair88.UUCP>
  4. Newsgroups: comp.sys.amiga.programmer
  5. Subject: DAT A/V
  6. Distribution: world
  7. References:  <2B26E48D.18374@ics.uci.edu>
  8. Date: 18 Dec 92 01:05:34 PST
  9. Organization: Only Amiga make's it possible
  10. Lines: 206
  11.  
  12.  
  13. So I got this DAT backup drive, and I was thinking about reading and
  14. displaying images with audio continuously.  Here are some calculations:
  15.  
  16. Assume DAT delivers 176,400b/s.  This is CD rate (44,100*2*2).  DAT
  17. actually delivers more because it goes 48,000 s/s, (the drive spec is like
  18. 184,000b/s) but we'll ignore that for now.  Plus, assuming 44,100 gives us
  19. something that works for CD-ROM too.
  20.  
  21. Assume 48,000 bytes/frame (simple HAM mode) for video image.  This divides
  22. out to 3.675 frames/s.  So let's go with 3 frames/sec, and the extra .675
  23. (32,400b/s) for audio.
  24.  
  25. 32,400b/s gives us a lot for a single channel of audio, or 2 channels at
  26. 16,200s/s, or a single high quality channel.  Since 3f/s is pretty meager
  27. video, 16,200s/s audio (8kHz cutoff) is adequate.
  28.  
  29. So every 1/3 second (20 video frames) we read 48,000b of video image, and
  30. 10,800 (32,400/3) bytes of audio.  Since we will want to double buffer, I
  31. would simply have 2 buffers of chip memory that has the 58,800 (48,000 +
  32. 10,800) byte buffers.
  33.  
  34. One more little detail.  We want the 16 color register for the HAM to look
  35. good.  Since each frame will display for 20 video frames, I'll make a
  36. copper list that is 20 frames long.  It will load the audio LOC once, then
  37. load the video, wait, load video, wait, (and so on for 20 frames), and swap
  38. buffers.  So there are 2 of these 20 frame long copper lists.  The end of
  39. one loads the address of the other into COP1LOC so as to page flip, and
  40. also interrupts the CPU to sync it (tell it to read the next buffer from
  41. tape).
  42.  
  43. Did you know that the copper can call a subroutine?  They conveniently
  44. provided that second copper address COP2LOC.  The COP1LOC is automatically
  45. loaded at VBLANK, but the second one is for whatever you want.  So you load
  46. the address of the subroutine in COP1LOC, the return address in COP2LOC,
  47. strobe COPJMP1 which jumps to the subroutine, which does whatever and ends
  48. with a strobe of COPJMP2 which returns.  This allows you to call a copper
  49. routine from multiple places in your copper list without changing memory.
  50. Just thought that one up, but not sure if I need that here, at least not
  51. the multiple call part (because colors only loaded once for the 20 frames).
  52.  
  53. What I did want to do is load a copper list fragment with the other stuff
  54. off the tape which could be a clean little piece of "position independent"
  55. copper code that I could call to load the 16 color registers.  Thus each
  56. (buffer-sized) block that I would load from tape would look like this:
  57.  
  58.     48,000    6 planes of HAM data
  59.         68    copper routine
  60.     10,800    audio data
  61.  
  62. Since the colors only need to be loaded once per image, the copper routine
  63. only needs to be called once, but having a routine like that means I just
  64. need to read the data into the buffer and don't need to fuck with it with
  65. the CPU (i.e.  merging data into a copper list).  The buffers are static and
  66. the copper lists are static.  Once I allocate the buffers, and write the
  67. copper lists, nothing needs to be changed.  Just read from tape.
  68.  
  69. So here is what I think the copper list would be like:
  70.  
  71. ; even buffer (a):
  72.  
  73. cop_list_a1:
  74.  
  75.     CWAIT    0,TOP_SCREEN-1        ; wait for scan line 44
  76.  
  77.     CMOVE    BPLCON0,(NUM_PLANES<<12)+512
  78.     CMOVE    BPLCON1,0        ; shift (none)
  79.     CMOVE    BPLCON2,36        ; priority (sprites on top)
  80.     CMOVE    DDFSTRT,$38        ; data fetch start
  81.     CMOVE    DDFSTOP,$D0        ; data fetch stop
  82.  
  83.     CMOVE    DIWSTRT,$2C81        ; window start
  84.     CMOVE    DIWSTOP,$F4C1        ; window stop
  85.  
  86.     CMOVE    BPL1MOD,PLANE_MODULO    ; modulos
  87.     CMOVE    BPL2MOD,PLANE_MODULO    ;
  88.  
  89.     CMOVEL    BPL0PT,plane0a        ; bit planes
  90.     CMOVEL    BPL1PT,plane1a        ;
  91.     CMOVEL    BPL2PT,plane2a        ;
  92.     CMOVEL    BPL3PT,plane3a        ;
  93.     CMOVEL    BPL4PT,plane4a        ;
  94.     CMOVEL    BPL5PT,plane5a        ;
  95.  
  96.     CMOVEL    SPR0PT,0        ; SPRITE POINTERS MUST BE LOADED
  97.     CMOVEL    SPR1PT,0        ; EVERY FRAME
  98.     CMOVEL    SPR2PT,0
  99.     CMOVEL    SPR3PT,0
  100.     CMOVEL    SPR4PT,0
  101.     CMOVEL    SPR5PT,0
  102.     CMOVEL    SPR6PT,0
  103.     CMOVEL    SPR7PT,0
  104.  
  105.     CMOVEL    AUD0LOC,buffer_a_audio_channel_1
  106.     CMOVEL    AUD1LOC,buffer_a_audio_channel_2
  107.  
  108. ; call copper routine for colors
  109.  
  110.     CMOVEL    COP1LOC,copcolor_a
  111.     CMOVEL    COP2LOC,return1a
  112.     CMOVE    COL1JMP,0        ; strobe
  113.  
  114. return1a:
  115.  
  116. ; wait bottom
  117.     CMOVEL    COP1LOC,cop_list_a2
  118.     CWAIT    255,255         ; wait for "BOVP"
  119.  
  120. cop_list_a2:
  121.  
  122. ( repeat above )
  123.  
  124. ; call copper routine for colors
  125.  
  126.     CMOVEL    COP1LOC,copcolor_a
  127.     CMOVEL    COP2LOC,return2a
  128.     CMOVE    COL1JMP,0        ; strobe
  129.  
  130. return2a:
  131.  
  132. ; wait bottom
  133.     CMOVEL    COP1LOC,cop_list_a3
  134.     CWAIT    255,255         ; wait for "BOVP"
  135.  
  136. cop_list_a3:
  137.  
  138. ...
  139.  
  140. ( repeat above for 20 frames )
  141.  
  142. cop_list_a20:
  143.  
  144. ; wait bottom
  145.     CMOVE    INTREQ,SET+INTF_COPER    ; notify CPU of page flip
  146. ( now we flip for double buffer )
  147.     CMOVEL    COP1LOC,cop_list_b1    ; flip to other copper list
  148.     CWAIT    255,255         ; wait for "BOVP"
  149.  
  150. ; odd buffer (b):
  151.  
  152. cop_list_b1:
  153.  
  154. ( this list like buffer a except we reference buffer b )
  155.  
  156. ... (20 frames of copper list)
  157.  
  158. ; wait bottom
  159.     CMOVE    INTREQ,SET+INTF_COPER    ; notify CPU of page flip
  160.     CMOVEL    COP1LOC,cop_list_a1    ; back to first buffer
  161.     CWAIT    255,255         ; wait for "BOVP"
  162.  
  163.  
  164. **************  double buffer in chipmem, filled by DAT read  ***************
  165.  
  166. buffer_a:
  167.  
  168. ; 48,000 bytes of plane data.
  169. plane0a: DS.B    8000
  170. plane1a: DS.B    8000
  171. plane2a: DS.B    8000
  172. plane3a: DS.B    8000
  173. plane4a: DS.B    8000
  174. plane5a: DS.B    8000
  175.  
  176. ; 68 byte of copper subroutine
  177. copcolor_a:
  178.     CMOVE    COLOR00,$04F
  179.     CMOVE    COLOR01,$09F
  180.     CMOVE    COLOR02,$0FC
  181.     CMOVE    COLOR03,$0F3
  182.     CMOVE    COLOR04,$6F0
  183.     CMOVE    COLOR05,$FF0
  184.     CMOVE    COLOR06,$FB0
  185.     CMOVE    COLOR07,$F70
  186.     CMOVE    COLOR08,$F40
  187.     CMOVE    COLOR09,$F00
  188.     CMOVE    COLOR10,$F05
  189.     CMOVE    COLOR11,$F0A
  190.     CMOVE    COLOR12,$F0E
  191.     CMOVE    COLOR13,$C0F
  192.     CMOVE    COLOR14,$80F
  193.     CMOVE    COLOR15,$40F
  194.     CMOVE    COPJMP2,0        ; "return"
  195. ; (actually just a DS.B 68, but this is what is read off tape)
  196.  
  197.  
  198. ; 10,800 bytes audio data
  199. buffer_a_audio_channel_1: DS.B 5400
  200. buffer_a_audio_channel_2: DS.B 5400
  201.  
  202. ; total: 58,868 bytes per buffer, loaded from DAT and swapped 3 times/sec.
  203.  
  204. buffer_b:
  205.  
  206. ; repeat as above
  207.  
  208.  
  209. Now if I only had enough video frames to actually do an animation!  (months
  210. of Rayshade!) If I get motivated, I'll just use some little repeated
  211. sequence of frames just to prove the viability of the idea.
  212.  
  213. DAT tapes come in 60, 90, and 120 minutes.  A feature length movie, at
  214. 3 fps.  If you could stand 160x100, you'd have 12 fps.  Tolerable.
  215.  
  216.  
  217. -- Jay Dresser, jdresser@altair88.net.netcom.com
  218.