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

  1.  > MakeDecomp
  2. $;" at line ";
  3.  code% 10000
  4. "Save <ARMovie$Dir>.Decomp10.Decompress "+
  5. ~code%+" "+
  6. ~tablestart%
  7. "OS_File",17,"<ARMovie$Dir>.Decomp10.MakeDecomp" 
  8.  ,,load%,exec%
  9. "OS_File",2,"<ARMovie$Dir>.Decomp10.Decompress",load%
  10. "OS_File",3,"<ARMovie$Dir>.Decomp10.Decompress",,exec%
  11. "Settype <ARMovie$Dir>.Decomp10.Decompress FFD"
  12. "Save <ARMovie$Dir>.Decomp10.DecompresH "+
  13. ~code%+" "+
  14. ~tablestart%
  15. "OS_File",2,"<ARMovie$Dir>.Decomp10.DecompresH",load%
  16. "OS_File",3,"<ARMovie$Dir>.Decomp10.DecompresH",,exec%
  17. "Settype <ARMovie$Dir>.Decomp10.DecompresH FFD"
  18. "Save <ARMovie$Dir>.Decomp10.Decom24 "+
  19. ~code%+" "+
  20. ~tablestart%
  21. "OS_File",2,"<ARMovie$Dir>.Decomp10.Decom24",load%
  22. "OS_File",3,"<ARMovie$Dir>.Decomp10.Decom24",,exec%
  23. "Settype <ARMovie$Dir>.Decomp10.Decom24 FFD"
  24. ass(half%,mash%)
  25. table%=0
  26. P%=code%:tablestart%=table%
  27. [OPT Z%
  28.  The decompressor
  29.  ================
  30.  The Player program will load the decompressor at a quad word aligned
  31.  address in memory. It will then process the patch table and then call
  32.  the init point. Later on the player will call the decompressor in USR
  33.  mode to decompress the first chunk's worth of frames (or to do -explode).
  34.  For a full play, the player will call the decompressor in IRQ mode.
  35.  Formal interface:
  36.  First word: patch table offset
  37.   Purpose: to allow the player to insert pixel colour lookup in the
  38.            decompressor. May in future allow other values to patched.
  39.            Note that an unpatched decompressor should still work!!
  40.   The offset table consists of words. Each word has the bottom 16 bits
  41.   as the offset of a word (usually an instruction) from the start of the
  42.   decompressor. The top 4 bits are an opcode number. The remaining 12
  43.   bits may have a meaning for that opcode. The list is terminated by a
  44.   word of -1.
  45.   Opcode 0: patch in colour lookup
  46.    bits 27..24: destination register
  47.    bits 23..20: source register
  48.    bits 19..17: pixel lookup table register
  49.   The Player alters the word to lookup the pixel colour. The value of
  50.   the source register and the size of the result in the destination
  51.   register may change for different decompressors. For format 2 the
  52.   source register value is either RGB or YUV 15 bits and the destination
  53.   value is always a word value. An unpatched format 2 decompressor
  54.   produces RGB or YUV output.
  55.  Second word: init entry point
  56.   Purpose: to allow the decompressor to initialise any tables that are
  57.            needed
  58.   On entry:
  59.     r0 - source x size of movie
  60.     r1 - source y size of movie
  61.     r2..r12 - scratch
  62.     r13 - stack
  63.     r14 - return address
  64.     processor mode: USR
  65.     flags - irrelevant
  66.  Third word: decompress entry point
  67.   Purpose: decompress precisely one frame
  68.   On entry:
  69.     r0 to r5 are set up by Player as follows:
  70.     r0 - source byte pointer
  71.     r1 - output pointer - save output pixels here
  72.     r2 - previous output pointer (allows copying from previous frame)
  73.     r3 - pixel dither lookup table
  74.     r4 - return address (can't be r14...)
  75.     r5..r12 - scratch
  76.     r13 - small stack (RISC OS irq stack)
  77.     r14 - unuseable
  78.     processor mode: IRQ, interrupts ENABLED (usually)
  79.     flags - irrelevant
  80.   On exit
  81.     r0 - next value of source byte pointer
  82.     r1..r12 - irrelevant
  83.     r13 - must be same value as on entry
  84.     r14 - irrelevant
  85.     processor mode: IRQ, interrupts ENABLED
  86.     flags - irrelevant
  87.  Usage for Decomp10 12bpp average
  88. dH      DCD table%-code% 
  89.  offset to patch table (or zero if no table)
  90. e#      B init 
  91.  initialise pixno
  92.       STMFD r13!,{r4}
  93.       LDR r2,ypix
  94. j    .decy
  95.       LDR r12,xpix
  96. half% 
  97. [OPT Z%
  98. o2      ADD r10,r1,r12,LSL #1  
  99.  next row output
  100. [OPT Z%
  101. s2      ADD r10,r1,r12,LSL #2  
  102.  next row output
  103. [OPT Z%
  104.   r0->source pixel stream
  105.   r1->upper destination row
  106.   r2=number of rows left
  107.   r3=dither pixel lookup table
  108.   r4-r9 unused
  109.   r10->lower destination row
  110.   r11 unused
  111.   r12=pixels left on this row pair
  112.   r13->FD stack
  113.     .decx
  114. 7      LDMIA r0 !,{r4,r5,r6}   
  115.  get 8 packed pixels
  116.  ---------- do first block of 4 pixels
  117.  r4=Y4Y3Y2Y1
  118.  r5=xxxxvvuu
  119. 4      MOV   r11, r5, LSL #16          
  120.  vvuu0000
  121. ; MOV r11, #0
  122. 3      
  123.    r7, r4, #&ff               
  124.  000000Y1
  125. 4      
  126. R   r7, r7, r11, LSR #8        
  127.  00vvuuY1
  128. 5      MOV   r4, r4, LSR #8             
  129.  00xxxxY2
  130. 3      
  131.    r8, r4, #&ff               
  132.  000000Y2
  133. 4      
  134. R   r8, r8, r11, LSR #8        
  135.  00vvuuY2
  136. 5      MOV   r4, r4, LSR #8             
  137.  0000xxY3
  138. 3      
  139.    r9, r4, #&ff               
  140.  000000Y3
  141. 4      
  142. R   r9, r9, r11, LSR #8        
  143.  00vvuuY3
  144. 4      
  145. R   r11, r4, r11               
  146.  vvuuY4xx
  147. 5      MOV   r11, r11, LSR #8           
  148.  00vvuuY4
  149. mash% 
  150. [OPT Z%
  151.       MOV   r4, #&1F
  152.       STMFD r13 !, {r9,r11}
  153.       
  154. crush(7 ,9,11,4)
  155.       
  156. crush(8 ,9,11,4)
  157.       LDMFD r13 !, {r9,r11}
  158. E      
  159. plook(7)              
  160.  record patch table entry for first
  161. F      
  162. plook(8)              
  163.  ..                           second
  164.       A%=
  165. write(1,7,8)
  166. mash% 
  167. [OPT Z%
  168.       
  169. crush(9 ,7,8,4)
  170.       
  171. crush(11,7,8,4)
  172. E      
  173. plook(9)              
  174.  ..                           third
  175. F      
  176. plook(11)             
  177.  ..                           fourth
  178.       A%=
  179. write(10,9,11)
  180.  ---------- do second block of 4 pixels
  181. [OPT Z%
  182.  r5=Y2Y1xxxx
  183.  r6=vvuuY4Y3
  184. 1      MOV   r11, r6, LSR #16       
  185.  0000VvUu
  186. ; MOV r11, #0
  187. 2      MOV   r5, r5, LSR #16         
  188.  0000Y2Y1
  189. 0      
  190.    r7, r5, #&ff            
  191.  000000Y1
  192. 1      
  193. R   r7, r7, r11, LSL #8     
  194.  00VvUuY1
  195. 2      MOV   r8, r5, LSR #8          
  196.  000000Y2
  197. 1      
  198. R   r8, r8, r11, LSL #8     
  199.  00VvUuY2
  200.       
  201.    r9, r6, #&ff
  202. 1      
  203. R   r9, r9, r11, LSL #8     
  204.  00VvUuY3
  205.       
  206.    r6, r6, #&ff00
  207.       MOV   r6, r6, LSR #8
  208. 1      
  209. R   r11, r6, r11, LSL #8    
  210.  00VvUuY4
  211. mash% 
  212. [OPT Z%
  213.       
  214. crush(7, 5,6,4)
  215.       
  216. crush(8 ,5,6,4)
  217.       
  218. crush(9 ,5,6,4)
  219.       
  220. crush(11,5,6,4)
  221. E      
  222. plook(7)              
  223.  record patch table entry for first
  224. F      
  225. plook(8)              
  226.  ..                           second
  227. E      
  228. plook(9)              
  229.  ..                           third
  230. F      
  231. plook(11)             
  232.  ..                           fourth
  233.       A%=
  234. write(1,7,8)
  235.       A%=
  236. write(10,9,11)
  237.  ------- check end of loops
  238. [OPT Z%
  239. =      SUBS  r12,r12,#4        
  240.  done 4 pixels on each row
  241.       BGT   decx
  242. 4      SUBS  r2,r2,#2          
  243.  done a line pair
  244.       MOVGT r1, r10
  245.       BGT   decy
  246. 6      LDMFD r13!,{pc}         
  247.  finished one frame
  248.  init is rather trivial
  249.     .init
  250.       STR r0, xpix
  251.       STR r1, ypix
  252.       MOVS pc,r14
  253. .xpix DCD 0
  254. .ypix DCD 0
  255. table%=P%
  256. "!tablestart%=-1:tablestart%+=4
  257.  record the lookup of dithered version of pixel
  258. plook(rn)
  259. table%<>0 
  260. A!tablestart%=&0000<<28 
  261.  rn<<24 
  262.  rn<<20 
  263.  3<<16 
  264.  (P%-code%)
  265. tablestart%+=4
  266. [OPT Z%
  267.  MOV rn,rn
  268. crush(rn,ri,rj,rM)
  269. [OPT Z%
  270.  ri,rM,rn,LSR #16+3
  271.  rj,rM,rn,LSR #8+3
  272. R ri,rj,ri,LSL #5
  273.  rj,rM,rn,LSR #3
  274. R rn,rj,ri,LSL #5
  275. write(rout,rA,rB)
  276. half% 
  277. [OPT Z%
  278.       
  279. R rA,rA,rB,LSL #16
  280. G      STMIA rout !,{rA}         
  281.  store 2 pixels into output line 1
  282. [OPT Z%
  283. G      STMIA rout !,{rA,rB}      
  284.  store 2 pixels into output line 1
  285.