home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-08-15 | 7.9 KB | 285 lines |
- > MakeDecomp
- $;" at line ";
- code% 10000
- "Save <ARMovie$Dir>.Decomp10.Decompress "+
- ~code%+" "+
- ~tablestart%
- "OS_File",17,"<ARMovie$Dir>.Decomp10.MakeDecomp"
- ,,load%,exec%
- "OS_File",2,"<ARMovie$Dir>.Decomp10.Decompress",load%
- "OS_File",3,"<ARMovie$Dir>.Decomp10.Decompress",,exec%
- "Settype <ARMovie$Dir>.Decomp10.Decompress FFD"
- "Save <ARMovie$Dir>.Decomp10.DecompresH "+
- ~code%+" "+
- ~tablestart%
- "OS_File",2,"<ARMovie$Dir>.Decomp10.DecompresH",load%
- "OS_File",3,"<ARMovie$Dir>.Decomp10.DecompresH",,exec%
- "Settype <ARMovie$Dir>.Decomp10.DecompresH FFD"
- "Save <ARMovie$Dir>.Decomp10.Decom24 "+
- ~code%+" "+
- ~tablestart%
- "OS_File",2,"<ARMovie$Dir>.Decomp10.Decom24",load%
- "OS_File",3,"<ARMovie$Dir>.Decomp10.Decom24",,exec%
- "Settype <ARMovie$Dir>.Decomp10.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
- Usage for Decomp10 12bpp average
- dH DCD table%-code%
- offset to patch table (or zero if no table)
- e# B init
- initialise pixno
- STMFD r13!,{r4}
- LDR r2,ypix
- j .decy
- LDR r12,xpix
- half%
- [OPT Z%
- o2 ADD r10,r1,r12,LSL #1
- next row output
- [OPT Z%
- s2 ADD r10,r1,r12,LSL #2
- next row output
- [OPT Z%
- r0->source pixel stream
- r1->upper destination row
- r2=number of rows left
- r3=dither pixel lookup table
- r4-r9 unused
- r10->lower destination row
- r11 unused
- r12=pixels left on this row pair
- r13->FD stack
- .decx
- 7 LDMIA r0 !,{r4,r5,r6}
- get 8 packed pixels
- ---------- do first block of 4 pixels
- r4=Y4Y3Y2Y1
- r5=xxxxvvuu
- 4 MOV r11, r5, LSL #16
- vvuu0000
- ; MOV r11, #0
- 3
- r7, r4, #&ff
- 000000Y1
- 4
- R r7, r7, r11, LSR #8
- 00vvuuY1
- 5 MOV r4, r4, LSR #8
- 00xxxxY2
- 3
- r8, r4, #&ff
- 000000Y2
- 4
- R r8, r8, r11, LSR #8
- 00vvuuY2
- 5 MOV r4, r4, LSR #8
- 0000xxY3
- 3
- r9, r4, #&ff
- 000000Y3
- 4
- R r9, r9, r11, LSR #8
- 00vvuuY3
- 4
- R r11, r4, r11
- vvuuY4xx
- 5 MOV r11, r11, LSR #8
- 00vvuuY4
- mash%
- [OPT Z%
- MOV r4, #&1F
- STMFD r13 !, {r9,r11}
-
- crush(7 ,9,11,4)
-
- crush(8 ,9,11,4)
- LDMFD r13 !, {r9,r11}
- E
- plook(7)
- record patch table entry for first
- F
- plook(8)
- .. second
- A%=
- write(1,7,8)
- mash%
- [OPT Z%
-
- crush(9 ,7,8,4)
-
- crush(11,7,8,4)
- E
- plook(9)
- .. third
- F
- plook(11)
- .. fourth
- A%=
- write(10,9,11)
- ---------- do second block of 4 pixels
- [OPT Z%
- r5=Y2Y1xxxx
- r6=vvuuY4Y3
- 1 MOV r11, r6, LSR #16
- 0000VvUu
- ; MOV r11, #0
- 2 MOV r5, r5, LSR #16
- 0000Y2Y1
- 0
- r7, r5, #&ff
- 000000Y1
- 1
- R r7, r7, r11, LSL #8
- 00VvUuY1
- 2 MOV r8, r5, LSR #8
- 000000Y2
- 1
- R r8, r8, r11, LSL #8
- 00VvUuY2
-
- r9, r6, #&ff
- 1
- R r9, r9, r11, LSL #8
- 00VvUuY3
-
- r6, r6, #&ff00
- MOV r6, r6, LSR #8
- 1
- R r11, r6, r11, LSL #8
- 00VvUuY4
- mash%
- [OPT Z%
-
- crush(7, 5,6,4)
-
- crush(8 ,5,6,4)
-
- crush(9 ,5,6,4)
-
- crush(11,5,6,4)
- E
- plook(7)
- record patch table entry for first
- F
- plook(8)
- .. second
- E
- plook(9)
- .. third
- F
- plook(11)
- .. fourth
- A%=
- write(1,7,8)
- A%=
- write(10,9,11)
- ------- check end of loops
- [OPT Z%
- = SUBS r12,r12,#4
- done 4 pixels on each row
- BGT decx
- 4 SUBS r2,r2,#2
- done a line pair
- MOVGT r1, r10
- BGT decy
- 6 LDMFD r13!,{pc}
- finished one frame
- init is rather trivial
- .init
- STR r0, xpix
- STR r1, ypix
- MOVS pc,r14
- .xpix DCD 0
- .ypix 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,rM)
- [OPT Z%
- ri,rM,rn,LSR #16+3
- rj,rM,rn,LSR #8+3
- R ri,rj,ri,LSL #5
- rj,rM,rn,LSR #3
- R rn,rj,ri,LSL #5
- write(rout,rA,rB)
- half%
- [OPT Z%
-
- R rA,rA,rB,LSL #16
- G STMIA rout !,{rA}
- store 2 pixels into output line 1
- [OPT Z%
- G STMIA rout !,{rA,rB}
- store 2 pixels into output line 1
-