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

  1.  > MakeDecomp
  2.  code% 10000
  3. "Save <ARMovie$Dir>.Decomp8.Decompress "+
  4. ~code%+" "+
  5. ~tablestart%
  6. "OS_File",17,"<ARMovie$Dir>.Decomp8.MakeDecomp" 
  7.  ,,load%,exec%
  8. "OS_File",2,"<ARMovie$Dir>.Decomp8.Decompress",load%
  9. "OS_File",3,"<ARMovie$Dir>.Decomp8.Decompress",,exec%
  10. "Settype <ARMovie$Dir>.Decomp8.Decompress FFD"
  11. "Save <ARMovie$Dir>.Decomp8.DecompresH "+
  12. ~code%+" "+
  13. ~tablestart%
  14. "OS_File",2,"<ARMovie$Dir>.Decomp8.DecompresH",load%
  15. "OS_File",3,"<ARMovie$Dir>.Decomp8.DecompresH",,exec%
  16. "Settype <ARMovie$Dir>.Decomp8.DecompresH FFD"
  17. "Save <ARMovie$Dir>.Decomp8.Decom24 "+
  18. ~code%+" "+
  19. ~tablestart%
  20. "OS_File",2,"<ARMovie$Dir>.Decomp8.Decom24",load%
  21. "OS_File",3,"<ARMovie$Dir>.Decomp8.Decom24",,exec%
  22. "Settype <ARMovie$Dir>.Decomp8.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. w7      LDMIA r0 !,{r6,r7,r8}   
  112.  get 4 packed pixels
  113. x9      BIC r9,r6,#&ff000000    
  114.  extract first (24bpp)
  115.       MOV r10,r7,LSL #8
  116. z1      
  117. R r10,r10,r6,LSR #24  
  118.  extract second
  119.       MOV r11,r8,LSL #16
  120.       
  121.  r11,r11,#&ff0000
  122. }0      
  123. R r11,r11,r7,LSR #16  
  124.  extract third
  125. ~2      MOV r12,r8,LSR #8       
  126.  extract fourth
  127. mash% 
  128. [OPT Z%
  129.       
  130. crush(9,6,7)
  131.       
  132. crush(10,6,7)
  133.       
  134. crush(11,6,7)
  135.       
  136. crush(12,6,7)
  137. E      
  138. plook(9)              
  139.  record patch table entry for first
  140. F      
  141. plook(10)             
  142.  ..                           second
  143. E      
  144. plook(11)             
  145.  ..                           third
  146. F      
  147. plook(12)             
  148.  ..                           fourth
  149. half% 
  150. [OPT Z%
  151.       
  152. R r8,r9,r10,LSL #16
  153.        
  154. R r10,r11,r12,LSL #16
  155. A      STMIA r1 !,{r8,r10} 
  156.  store 4 pixels into output buffer
  157. [OPT Z%
  158. I      STMIA r1 !,{r9,r10,r11,r12} 
  159.  store 4 pixels into output buffer
  160. [OPT Z%
  161. '      SUBS r5,r5,#4 
  162.  done 4 pixels
  163.       BNE decloop
  164. (      MOV pc,r4 
  165.  finished one frame
  166.  init is rather trivial
  167.     .init
  168. Y      MUL r2,r0,r1  
  169.  compute total number of pixels in frame (must be multiple of 4)
  170. )      STR r2,pixno  
  171.  and remember it
  172.       MOVS pc,r14
  173. .pixno DCD 0
  174. table%=P%
  175. "!tablestart%=-1:tablestart%+=4
  176.  record the lookup of dithered version of pixel
  177. plook(rn)
  178. table%<>0 
  179. A!tablestart%=&0000<<28 
  180.  rn<<24 
  181.  rn<<20 
  182.  3<<16 
  183.  (P%-code%)
  184. tablestart%+=4
  185. [OPT Z%
  186.  MOV rn,rn
  187. crush(rn,ri,rj)
  188. [OPT Z%
  189.  ri,r2,rn,LSR #16+3
  190.  rj,r2,rn,LSR #8+3
  191. R ri,rj,ri,LSL #5
  192.  rj,r2,rn,LSR #3
  193. R rn,rj,ri,LSL #5
  194.