home *** CD-ROM | disk | FTP | other *** search
- ; GenTab.a
- ;─────────────────────────────────────────────────────────────────────────────
- ; Generate Huffman decode tables for LHARC self extract module
- ;─────────────────────────────────────────────────────────────────────────────
- ; Routine to generate the following tables:
- ;
- ; d_code - 256 bytes. Huffman codes (partial)
- ; d_len - 256 bytes. Huffman code lengths
- ;
- ; It would be simpler to just store the tables, but generating them makes for
- ; a smaller executable by about 400 bytes or so.
- ;
-
- INSTXT "sfx.i"
-
- PUBLIC GenTab
- PUBLIC d_code
- PUBLIC d_len
-
- BSS d_code,256
- BSS d_len,256
-
- PNT = T0
- TIMES = T1+2
- save_y = T2+3
-
- GenTab lda #<d_code
- sta PNT
- lda #>d_code
- sta PNT+1
-
- ldy #0 ; .y is index into d_c
- tya ; .a is d_code value
-
- gdc5 pha
- lda d_c+1,y ; and how many times to do it
- beq gdc22
- sta TIMES
- pla
- gdc3 ldx d_c,y ; .x is how many to store
- gdc4 jsr store
- dex
- bne gdc4
- clc
- adc #1
- dec TIMES
- bne gdc3
- iny
- iny
- jmp gdc5
-
- gdc22 pla
- gdc23 iny
- iny
- gdc2 lda d_c,y ; Now .a is value
- ldx d_c+1,y ; and .x is how many
- bne gdc1
- rts
-
- gdc1 jsr store
- dex
- bne gdc1
- beq gdc23
-
- store sty save_y
- ldy #0
- sta (PNT),y
- inc PNT
- bne stor1
- inc PNT+1
- stor1 ldy save_y
- rts
-
- d_c fcb $20,1,$10,3,$08,8,$04,12,$02,24,$01,16
- fcb 0,0
- fcb $03,$20,$04,$30,$05,$40,$06,$30,$07,$30,$08,$10
- fcb 0,0
-
- END
-