/[projet1]/public/atari/demos/defenceforce/savetheearth/depack.s
Defence Force logotype

Contents of /public/atari/demos/defenceforce/savetheearth/depack.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (show annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years, 3 months ago) by dbug
File size: 2551 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1
2
3 ;
4 ; Depacking description
5 ;
6 rsreset
7 depack_source rs.l 1 ; Pointer to the source (compressed)
8 depack_destination rs.l 1 ; Pointer to the destination (decompressed)
9 depack_size rs.l 1 ; Size of the decompressed data
10
11
12 SECTION TEXT
13
14 even
15
16 ; a0=Source (compressed) data
17 ; a1=Destination buffer
18 ; d0.l=destination buffer size
19 DepackDelta
20 movem.l d0-a6,-(sp)
21
22 lea DepackDeltaTable,a2
23 move.b (a0)+,d1 ; Start value
24 eor.b #$80,d1 ; Sign change
25 move.b d1,(a1)+
26
27 moveq #0,d2
28 .loop
29 REPT 4
30 move.b (a0)+,d2 ; Fetch two nibbles
31
32 add.b (a2,d2),d1
33 move.b d1,(a1)+
34
35 lsr #4,d2
36 add.b (a2,d2),d1
37 move.b d1,(a1)+
38 ENDR
39
40 subq.l #2*4,d0
41 bpl.s .loop
42
43 movem.l (sp)+,d0-a6
44 rts
45
46
47 ; a0=pointer on the first depack description block
48 ; d0=number of blocks to depack
49 DepackBlockMulti
50 subq #1,d0
51 .loop
52 movem.l d0/a0,-(sp)
53 bsr DepackBlock
54 movem.l (sp)+,d0/a0
55 lea 12(a0),a0
56 dbra d0,.loop
57 rts
58
59
60 ; a0=pointer on the depack description block
61 DepackBlock
62 movem.l d0/a0/a1,-(sp)
63 move.l depack_destination(a0),a1
64 move.l depack_size(a0),d0
65 move.l depack_source(a0),a0
66 bsr DepackLz77
67 movem.l (sp)+,d0/a0/a1
68 rts
69
70 ; a0=Source (compressed) data
71 ; a1=Destination buffer
72 ; d0.l=destination buffer size
73 DepackLz77
74 movem.l d0/a0/a1,-(sp)
75
76 moveq #0,d1 ; mask
77 moveq #0,d3
78 moveq #0,d4
79
80 .loop
81 ; Test mask
82 add.b d1,d1 ; Adjust mask
83 bne.s .mask_ok
84 ; Init mask and reload value
85 moveq #1,d1
86 move.b (a0)+,d2 ; value
87 .mask_ok
88
89 ; Test single byte copy
90 lsr.b #1,d2
91 bcc.s .copy_single_byte
92
93 .copy_from_offset
94 ; temp clearing, just to get it to work
95 moveq #0,d5
96 move.b (a0)+,d3 ; Offset, low byte
97 move.b (a0)+,d4 ; Offset, high nibble (top four bits: count)
98
99 move.b d4,d5
100 lsr.b #4,d5
101 addq.b #3,d5 ; Final size
102 sub.l d5,d0 ; Adjust size
103
104 and.b #$0f,d4
105 lsl.w #8,d4
106 or.w d3,d4
107 addq.w #1,d4 ; Get fulloffset
108
109 move.l a1,a2 ; Copy dest
110 sub d4,a2 ; -Offset
111
112 add.w d5,d5 ; Jump into unrolled string copy loop
113 neg.w d5
114 jmp .unroll(pc,d5.w)
115
116 REPT 18
117 move.b (a2)+,(a1)+
118 ENDR
119 .unroll
120
121 tst.l d0
122 bpl.s .loop
123 movem.l (sp)+,d0/a0/a1
124 rts
125
126
127 .copy_single_byte
128 move.b (a0)+,(a1)+
129 subq.l #1,d0 ; Adjust size
130 bpl.s .loop
131 movem.l (sp)+,d0/a0/a1
132 rts
133
134
135 SECTION DATA
136
137 even
138
139 DepackDeltaTable
140 REPT 16
141 dc.b -64
142 dc.b -32
143 dc.b -16
144 dc.b -8
145 dc.b -4
146 dc.b -2
147 dc.b -1
148 dc.b 0
149 dc.b 1
150 dc.b 2
151 dc.b 4
152 dc.b 8
153 dc.b 16
154 dc.b 32
155 dc.b 64
156 dc.b 127
157 ENDR
158
159

  ViewVC Help
Powered by ViewVC 1.1.26