home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / c128 / util / sfxsrc.lzh / GENTAB.A < prev    next >
Encoding:
Text File  |  1990-02-12  |  2.0 KB  |  80 lines

  1. ; GenTab.a
  2. ;─────────────────────────────────────────────────────────────────────────────
  3. ; Generate Huffman decode tables for LHARC self extract module
  4. ;─────────────────────────────────────────────────────────────────────────────
  5. ; Routine to generate the following tables:
  6. ;
  7. ;           d_code - 256 bytes. Huffman codes (partial)
  8. ;           d_len  - 256 bytes. Huffman code lengths
  9. ;
  10. ; It would be simpler to just store the tables, but generating them makes for
  11. ; a smaller executable by about 400 bytes or so.
  12. ;
  13.  
  14.             INSTXT "sfx.i"
  15.  
  16.             PUBLIC GenTab
  17.             PUBLIC d_code
  18.             PUBLIC d_len
  19.  
  20.             BSS d_code,256
  21.             BSS d_len,256
  22.  
  23. PNT         = T0
  24. TIMES       = T1+2
  25. save_y      = T2+3
  26.  
  27. GenTab      lda #<d_code
  28.             sta PNT
  29.             lda #>d_code
  30.             sta PNT+1
  31.  
  32.             ldy #0                  ; .y is index into d_c
  33.             tya                     ; .a is d_code value
  34.  
  35. gdc5        pha
  36.             lda d_c+1,y             ; and how many times to do it
  37.             beq gdc22
  38.             sta TIMES
  39.             pla
  40. gdc3        ldx d_c,y               ; .x is how many to store
  41. gdc4        jsr store
  42.             dex
  43.             bne gdc4
  44.             clc
  45.             adc #1
  46.             dec TIMES
  47.             bne gdc3
  48.             iny
  49.             iny
  50.             jmp gdc5
  51.  
  52. gdc22       pla
  53. gdc23       iny
  54.             iny
  55. gdc2        lda d_c,y               ; Now .a is value
  56.             ldx d_c+1,y             ; and .x is how many
  57.             bne gdc1
  58.             rts
  59.  
  60. gdc1        jsr store
  61.             dex
  62.             bne gdc1
  63.             beq gdc23
  64.  
  65. store       sty save_y
  66.             ldy #0
  67.             sta (PNT),y
  68.             inc PNT
  69.             bne stor1
  70.             inc PNT+1
  71. stor1       ldy save_y
  72.             rts
  73.  
  74. d_c         fcb $20,1,$10,3,$08,8,$04,12,$02,24,$01,16
  75.             fcb 0,0
  76.             fcb $03,$20,$04,$30,$05,$40,$06,$30,$07,$30,$08,$10
  77.             fcb 0,0
  78.  
  79.             END
  80.