home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / _armovie / decomp9 / makedecomp (.txt) < prev   
Encoding:
RISC OS BBC BASIC V Source  |  1994-08-15  |  6.3 KB  |  196 lines

  1.  > MakeDecomp
  2.  code% 10000
  3. "Save <ARMovie$Dir>.Decomp9.Decompress "+
  4. ~code%+" "+
  5. ~tablestart%
  6. "OS_File",17,"<ARMovie$Dir>.Decomp9.MakeDecomp" 
  7.  ,,load%,exec%
  8. "OS_File",2,"<ARMovie$Dir>.Decomp9.Decompress",load%
  9. "OS_File",3,"<ARMovie$Dir>.Decomp9.Decompress",,exec%
  10. "Settype <ARMovie$Dir>.Decomp9.Decompress FFD"
  11. "Save <ARMovie$Dir>.Decomp9.DecompresH "+
  12. ~code%+" "+
  13. ~tablestart%
  14. "OS_File",2,"<ARMovie$Dir>.Decomp9.DecompresH",load%
  15. "OS_File",3,"<ARMovie$Dir>.Decomp9.DecompresH",,exec%
  16. "Settype <ARMovie$Dir>.Decomp9.DecompresH FFD"
  17. "Save <ARMovie$Dir>.Decomp9.Decom24 "+
  18. ~code%+" "+
  19. ~tablestart%
  20. "OS_File",2,"<ARMovie$Dir>.Decomp9.Decom24",load%
  21. "OS_File",3,"<ARMovie$Dir>.Decomp9.Decom24",,exec%
  22. "Settype <ARMovie$Dir>.Decomp9.Decom24 FFD"
  23. ass(half%,mash%)
  24. table%=0
  25. P%=code%:tablestart%=table%
  26. [OPT Z%
  27.  The decompressor
  28.  ================
  29.  The Player program will load the decompressor at a quad word aligned
  30.  address in memory. It will then process the patch table and then call
  31.  the init point. Later on the player will call the decompressor in USR
  32.  mode to decompress the first chunk's worth of frames (or to do -explode).
  33.  For a full play, the player will call the decompressor in IRQ mode.
  34.  Formal interface:
  35.  First word: patch table offset
  36.   Purpose: to allow the player to insert pixel colour lookup in the
  37.            decompressor. May in future allow other values to patched.
  38.            Note that an unpatched decompressor should still work!!
  39.   The offset table consists of words. Each word has the bottom 16 bits
  40.   as the offset of a word (usually an instruction) from the start of the
  41.   decompressor. The top 4 bits are an opcode number. The remaining 12
  42.   bits may have a meaning for that opcode. The list is terminated by a
  43.   word of -1.
  44.   Opcode 0: patch in colour lookup
  45.    bits 27..24: destination register
  46.    bits 23..20: source register
  47.    bits 19..17: pixel lookup table register
  48.   The Player alters the word to lookup the pixel colour. The value of
  49.   the source register and the size of the result in the destination
  50.   register may change for different decompressors. For format 2 the
  51.   source register value is either RGB or YUV 15 bits and the destination
  52.   value is always a word value. An unpatched format 2 decompressor
  53.   produces RGB or YUV output.
  54.  Second word: init entry point
  55.   Purpose: to allow the decompressor to initialise any tables that are
  56.            needed
  57.   On entry:
  58.     r0 - source x size of movie
  59.     r1 - source y size of movie
  60.     r2..r12 - scratch
  61.     r13 - stack
  62.     r14 - return address
  63.     processor mode: USR
  64.     flags - irrelevant
  65.  Third word: decompress entry point
  66.   Purpose: decompress precisely one frame
  67.   On entry:
  68.     r0 to r5 are set up by Player as follows:
  69.     r0 - source byte pointer
  70.     r1 - output pointer - save output pixels here
  71.     r2 - previous output pointer (allows copying from previous frame)
  72.     r3 - pixel dither lookup table
  73.     r4 - return address (can't be r14...)
  74.     r5..r12 - scratch
  75.     r13 - small stack (RISC OS irq stack)
  76.     r14 - unuseable
  77.     processor mode: IRQ, interrupts ENABLED (usually)
  78.     flags - irrelevant
  79.   On exit
  80.     r0 - next value of source byte pointer
  81.     r1..r12 - irrelevant
  82.     r13 - must be same value as on entry
  83.     r14 - irrelevant
  84.     processor mode: IRQ, interrupts ENABLED
  85.     flags - irrelevant
  86.   The format 2 decompressor saves pixels as Words!!! For format 2
  87.   to work, the source pointer must be word aligned.
  88.   format 2 actual usage
  89.   The main entrypoint is at .decl
  90.   register usage:
  91.     r0 - source byte pointer (word aligned)
  92.     r1 - output pointer - save output pixels in words here
  93.     r2 - 0x1f - useful for extracting 5-bit values
  94.     r3 - pixel dither lookup table
  95.     r4 - return address
  96.     r5 - number of pixels
  97. nH      DCD table%-code% 
  98.  offset to patch table (or zero if no table)
  99. o#      B init 
  100.  initialise pixno
  101.       MOV r2,#&1f
  102.       LDR r5,pixno
  103.       ADD r5,r5,#3
  104. sR      BIC r5,r5,#3            
  105.  just to stop any nastiness, make multiple of 4
  106. tE      MOV r0,r0               
  107.  quad word align decompressor loop
  108. uE      MOV r0,r0               
  109.  quad word align decompressor loop
  110. .decloop
  111. w<      LDMIA r0 !,{r6,r7}      
  112.  get 4 packed pixels VUYY
  113. y2      MOV r12,r7,LSR#8        
  114.  extract fourth
  115.       MOV r11,r7,LSR#16
  116.       
  117.  r7,r7,#&ff
  118. |0      
  119. R r11,r7,r11,LSL#8    
  120.  extract third
  121. ~2      MOV r10,r6,LSR#8        
  122.  extract second
  123.       MOV r9,r6,LSR#16
  124.       
  125.  r6,r6,#&ff
  126. 0      
  127. R r9,r6,r9,LSL#8      
  128.  extract first
  129. mash% 
  130. [OPT Z%
  131.       
  132. crush(9,6,7)
  133.       
  134. crush(10,6,7)
  135.       
  136. crush(11,6,7)
  137.       
  138. crush(12,6,7)
  139. E      
  140. plook(9)              
  141.  record patch table entry for first
  142. F      
  143. plook(10)             
  144.  ..                           second
  145. E      
  146. plook(11)             
  147.  ..                           third
  148. F      
  149. plook(12)             
  150.  ..                           fourth
  151. half% 
  152. [OPT Z%
  153.       
  154. R r8,r9,r10,LSL #16
  155.        
  156. R r10,r11,r12,LSL #16
  157. A      STMIA r1 !,{r8,r10} 
  158.  store 4 pixels into output buffer
  159. [OPT Z%
  160. I      STMIA r1 !,{r9,r10,r11,r12} 
  161.  store 4 pixels into output buffer
  162. [OPT Z%
  163. '      SUBS r5,r5,#4 
  164.  done 4 pixels
  165.       BNE decloop
  166. (      MOV pc,r4 
  167.  finished one frame
  168.  init is rather trivial
  169.     .init
  170. Y      MUL r2,r0,r1  
  171.  compute total number of pixels in frame (must be multiple of 4)
  172. )      STR r2,pixno  
  173.  and remember it
  174.       MOVS pc,r14
  175. .pixno DCD 0
  176. table%=P%
  177. "!tablestart%=-1:tablestart%+=4
  178.  record the lookup of dithered version of pixel
  179. plook(rn)
  180. table%<>0 
  181. A!tablestart%=&0000<<28 
  182.  rn<<24 
  183.  rn<<20 
  184.  3<<16 
  185.  (P%-code%)
  186. tablestart%+=4
  187. [OPT Z%
  188.  MOV rn,rn
  189. crush(rn,ri,rj)
  190. [OPT Z%
  191.  ri,r2,rn,LSR #16+3
  192.  rj,r2,rn,LSR #8+3
  193. R ri,rj,ri,LSL #5
  194.  rj,r2,rn,LSR #3
  195. R rn,rj,ri,LSL #5
  196.