home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-08-15 | 6.3 KB | 194 lines |
- > MakeDecomp
- code% 10000
- "Save <ARMovie$Dir>.Decomp8.Decompress "+
- ~code%+" "+
- ~tablestart%
- "OS_File",17,"<ARMovie$Dir>.Decomp8.MakeDecomp"
- ,,load%,exec%
- "OS_File",2,"<ARMovie$Dir>.Decomp8.Decompress",load%
- "OS_File",3,"<ARMovie$Dir>.Decomp8.Decompress",,exec%
- "Settype <ARMovie$Dir>.Decomp8.Decompress FFD"
- "Save <ARMovie$Dir>.Decomp8.DecompresH "+
- ~code%+" "+
- ~tablestart%
- "OS_File",2,"<ARMovie$Dir>.Decomp8.DecompresH",load%
- "OS_File",3,"<ARMovie$Dir>.Decomp8.DecompresH",,exec%
- "Settype <ARMovie$Dir>.Decomp8.DecompresH FFD"
- "Save <ARMovie$Dir>.Decomp8.Decom24 "+
- ~code%+" "+
- ~tablestart%
- "OS_File",2,"<ARMovie$Dir>.Decomp8.Decom24",load%
- "OS_File",3,"<ARMovie$Dir>.Decomp8.Decom24",,exec%
- "Settype <ARMovie$Dir>.Decomp8.Decom24 FFD"
- ass(half%,mash%)
- table%=0
- P%=code%:tablestart%=table%
- [OPT Z%
- The decompressor
- ================
- The Player program will load the decompressor at a quad word aligned
- address in memory. It will then process the patch table and then call
- the init point. Later on the player will call the decompressor in USR
- mode to decompress the first chunk's worth of frames (or to do -explode).
- For a full play, the player will call the decompressor in IRQ mode.
- Formal interface:
- First word: patch table offset
- Purpose: to allow the player to insert pixel colour lookup in the
- decompressor. May in future allow other values to patched.
- Note that an unpatched decompressor should still work!!
- The offset table consists of words. Each word has the bottom 16 bits
- as the offset of a word (usually an instruction) from the start of the
- decompressor. The top 4 bits are an opcode number. The remaining 12
- bits may have a meaning for that opcode. The list is terminated by a
- word of -1.
- Opcode 0: patch in colour lookup
- bits 27..24: destination register
- bits 23..20: source register
- bits 19..17: pixel lookup table register
- The Player alters the word to lookup the pixel colour. The value of
- the source register and the size of the result in the destination
- register may change for different decompressors. For format 2 the
- source register value is either RGB or YUV 15 bits and the destination
- value is always a word value. An unpatched format 2 decompressor
- produces RGB or YUV output.
- Second word: init entry point
- Purpose: to allow the decompressor to initialise any tables that are
- needed
- On entry:
- r0 - source x size of movie
- r1 - source y size of movie
- r2..r12 - scratch
- r13 - stack
- r14 - return address
- processor mode: USR
- flags - irrelevant
- Third word: decompress entry point
- Purpose: decompress precisely one frame
- On entry:
- r0 to r5 are set up by Player as follows:
- r0 - source byte pointer
- r1 - output pointer - save output pixels here
- r2 - previous output pointer (allows copying from previous frame)
- r3 - pixel dither lookup table
- r4 - return address (can't be r14...)
- r5..r12 - scratch
- r13 - small stack (RISC OS irq stack)
- r14 - unuseable
- processor mode: IRQ, interrupts ENABLED (usually)
- flags - irrelevant
- On exit
- r0 - next value of source byte pointer
- r1..r12 - irrelevant
- r13 - must be same value as on entry
- r14 - irrelevant
- processor mode: IRQ, interrupts ENABLED
- flags - irrelevant
- The format 2 decompressor saves pixels as Words!!! For format 2
- to work, the source pointer must be word aligned.
- format 2 actual usage
- The main entrypoint is at .decl
- register usage:
- r0 - source byte pointer (word aligned)
- r1 - output pointer - save output pixels in words here
- r2 - 0x1f - useful for extracting 5-bit values
- r3 - pixel dither lookup table
- r4 - return address
- r5 - number of pixels
- nH DCD table%-code%
- offset to patch table (or zero if no table)
- o# B init
- initialise pixno
- MOV r2,#&1f
- LDR r5,pixno
- ADD r5,r5,#3
- sR BIC r5,r5,#3
- just to stop any nastiness, make multiple of 4
- tE MOV r0,r0
- quad word align decompressor loop
- uE MOV r0,r0
- quad word align decompressor loop
- .decloop
- w7 LDMIA r0 !,{r6,r7,r8}
- get 4 packed pixels
- x9 BIC r9,r6,#&ff000000
- extract first (24bpp)
- MOV r10,r7,LSL #8
- z1
- R r10,r10,r6,LSR #24
- extract second
- MOV r11,r8,LSL #16
-
- r11,r11,#&ff0000
- }0
- R r11,r11,r7,LSR #16
- extract third
- ~2 MOV r12,r8,LSR #8
- extract fourth
- mash%
- [OPT Z%
-
- crush(9,6,7)
-
- crush(10,6,7)
-
- crush(11,6,7)
-
- crush(12,6,7)
- E
- plook(9)
- record patch table entry for first
- F
- plook(10)
- .. second
- E
- plook(11)
- .. third
- F
- plook(12)
- .. fourth
- half%
- [OPT Z%
-
- R r8,r9,r10,LSL #16
-
- R r10,r11,r12,LSL #16
- A STMIA r1 !,{r8,r10}
- store 4 pixels into output buffer
- [OPT Z%
- I STMIA r1 !,{r9,r10,r11,r12}
- store 4 pixels into output buffer
- [OPT Z%
- ' SUBS r5,r5,#4
- done 4 pixels
- BNE decloop
- ( MOV pc,r4
- finished one frame
- init is rather trivial
- .init
- Y MUL r2,r0,r1
- compute total number of pixels in frame (must be multiple of 4)
- ) STR r2,pixno
- and remember it
- MOVS pc,r14
- .pixno DCD 0
- table%=P%
- "!tablestart%=-1:tablestart%+=4
- record the lookup of dithered version of pixel
- plook(rn)
- table%<>0
- A!tablestart%=&0000<<28
- rn<<24
- rn<<20
- 3<<16
- (P%-code%)
- tablestart%+=4
- [OPT Z%
- MOV rn,rn
- crush(rn,ri,rj)
- [OPT Z%
- ri,r2,rn,LSR #16+3
- rj,r2,rn,LSR #8+3
- R ri,rj,ri,LSL #5
- rj,r2,rn,LSR #3
- R rn,rj,ri,LSL #5
-