Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; decompress.asm
- ; Data decompression
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;.include "../macros.asm"
- .macro dcmp_fetch_byte
- lda [dcmp_srcadd],y
- iny
- bne :+
- jsr dcmp_nextbank
- :
- ; next code
- .endmac
- .macro dcmp_chk_lz_end
- pha
- lda dcmp_lzcctr
- beq :+
- jsr dcmp_declzcctr
- :
- pla
- .endmac
- label_80a116:
- php
- phb
- regsize 2, 2
- ldy dcmp_srcadd
- stz dcmp_srcadd
- regsize 1, NULL
- stz dcmp_lzcctr
- lda dcmp_dstbnk
- pha
- plb
- ldx dcmp_dstadd
- jmp dcmp_main
- dcmp_fetch:
- dcmp_fetch_byte
- dcmp_chk_lz_end
- rts
- dcmp_declzcctr:
- dec
- sta dcmp_lzcctr
- bne :+
- lda dcmp_bnkstr
- sta dcmp_srcbnk
- ldy dcmp_addstr
- :
- rts
- dcmp_nextbank:
- inc dcmp_srcbnk
- ldy #$8000
- rts
- dcmp_nibl30:
- sta dcmp_work
- asl
- bpl dcmp_nibl50
- and #$20
- beq dcmp_nibl40
- lda dcmp_work
- asl
- asl
- asl
- asl
- ora #$0f
- sta a:$0000,x
- inx
- lda #$1f
- bra dcmp_nibl10
- dcmp_nibl40:
- lda dcmp_work
- and #$0f
- ora #$f0
- sta a:$0000,x
- inx
- lda #$0f
- bra dcmp_nibl10
- dcmp_nibl50:
- and #$20
- beq dcmp_nibl60
- lda dcmp_work
- asl
- asl
- asl
- asl
- sta a:$0000,x
- inx
- lda #$10
- bra dcmp_nibl10
- dcmp_nibl60:
- lda dcmp_work
- and #$0f
- sta a:$0000,x
- inx
- lda #$00
- bra dcmp_nibl10
- dcmp_nibl:
- and #$0f
- inc
- sta dcmp_work+2
- jsr dcmp_fetch
- cmp #$80
- bcs dcmp_nibl30
- dcmp_nibl10:
- cmp #$10
- bcc dcmp_nibl20
- and #$0f
- sta dcmp_work
- dcmp_nibl15:
- jsr dcmp_fetch
- sta dcmp_work+1
- and #$f0
- ora dcmp_work
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bmi dcmp_niblr
- lda dcmp_work+1
- asl
- asl
- asl
- asl
- ora dcmp_work
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl dcmp_nibl15
- jmp dcmp_main
- dcmp_nibl20:
- asl
- asl
- asl
- asl
- sta dcmp_work
- dcmp_nibl25:
- jsr dcmp_fetch
- sta dcmp_work+1
- lsr
- lsr
- lsr
- lsr
- ora dcmp_work
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bmi dcmp_niblr
- lda dcmp_work+1
- and #$0f
- ora dcmp_work
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl dcmp_nibl25
- dcmp_niblr:
- jmp dcmp_main
- dcmp_chkcmdmsk10:
- cmp #%01010000
- bcc dcmp_nibl
- and #$0f
- sta dcmp_work+2
- dcmp_rep2:
- dcmp_fetch_byte
- dcmp_chk_lz_end
- sta a:$0000,x
- inx
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl dcmp_rep2
- jmp dcmp_main
- dcmp_chkcmdmsk:
- lsr
- cmp #%01100000
- bcc dcmp_chkcmdmsk10
- xba
- dcmp_fetch_byte
- dcmp_chk_lz_end
- sta dcmp_work
- xba
- cmp #%01110000
- and #$0f
- inc
- sta dcmp_work+2
- bcs dcmp_alt2
- dcmp_alt1:
- lda dcmp_work
- sta a:$0000,x
- inx
- dcmp_fetch_byte
- dcmp_chk_lz_end
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl dcmp_alt1
- bra dcmp_main
- dcmp_alt2:
- dcmp_fetch_byte
- dcmp_chk_lz_end
- sta a:$0000,x
- inx
- lda dcmp_work
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl dcmp_alt2
- bra dcmp_main
- dcmp_bitmskcmd:
- bmi dcmp_chkcmdmsk
- lsr
- sta dcmp_work+2
- dcmp_rawd:
- dcmp_fetch_byte
- dcmp_chk_lz_end
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl dcmp_rawd
- dcmp_main:
- dcmp_fetch_byte
- dcmp_chk_lz_end
- asl
- bcc dcmp_bitmskcmd
- bmi dcmp_prefixcmd
- lsr
- pha
- lsr
- lsr
- inc
- sta dcmp_work+2
- pla
- and #$03
- xba
- label_80a2c2:
- dcmp_fetch_byte
- phy
- regsize 2, NULL
- sta dcmp_work
- txa
- sec
- sbc dcmp_work
- tay
- regsize 1, NULL
- label_80a2d6:
- lda a:$0000,y
- sta a:$0000,x
- iny
- inx
- dec dcmp_work+2
- bpl label_80a2d6
- ply
- label_80a2e3:
- lda dcmp_lzcctr
- beq dcmp_main
- jsr dcmp_declzcctr
- bra dcmp_main
- dcmp_prefixcmd:
- ror
- cmp #%11100000
- bcs dcmp_rle1
- and #$1f
- xba
- dcmp_fetch_byte
- dcmp_chk_lz_end
- regsize 2, NULL
- asl
- regsize 1, NULL
- lsr
- xba
- inc
- sta dcmp_work+2
- bra label_80a2c2
- dcmp_rle1:
- cmp #%11110000
- bcs dcmp_rle2
- and #%00001111
- sta dcmp_work+1
- dcmp_fetch_byte
- dcmp_chk_lz_end
- sta dcmp_work
- dcmp_fetch_byte
- phy
- pha
- pha
- regsize 2, NULL
- lda dcmp_work
- clc
- adc #3
- lsr
- tay
- pla
- dcmp_rle1_10:
- sta a:$0000,x
- inx
- inx
- dey
- bne dcmp_rle1_10
- regsize 1, NULL
- bcc dcmp_rle1_20
- sta a:$0000,x
- inx
- dcmp_rle1_20:
- ply
- bra label_80a2e3
- dcmp_rle2:
- cmp #%11111000
- bcs dcmp_lzcf
- and #%00000111
- adc #2
- sta dcmp_work+2
- dcmp_fetch_byte
- label_80a367:
- sta a:$0000,x
- inx
- dec dcmp_work+2
- bpl label_80a367
- jmp label_80a2e3
- dcmp_lzcf:
- cmp #%11111100
- bcs dcmp_lzcn
- and #%00000011
- xba
- dcmp_fetch_byte
- regsize 2, NULL
- asl
- asl
- asl
- regsize 1, NULL
- lsr
- lsr
- lsr
- xba
- pha
- dcmp_fetch_byte
- regsize 2, NULL
- clc
- adc #3
- dcmp_lzc_calc:
- sty dcmp_addstr
- sta dcmp_work
- regsize 1, NULL
- lda dcmp_srcbnk
- sta dcmp_bnkstr
- regsize 2, NULL
- tya
- sec
- sbc dcmp_work
- bmi label_80a3b3
- clc
- adc #$8000
- dec dcmp_srcbnk
- label_80a3b3:
- tay
- regsize 1, NULL
- pla
- clc
- adc #3
- sta dcmp_lzcctr
- jmp dcmp_main
- dcmp_lzcn:
- cmp #%11111110
- bcs dcmpret
- and #%00000001
- xba
- dcmp_fetch_byte
- regsize 2, NULL
- asl
- asl
- regsize 1, NULL
- xba
- pha
- xba
- lsr
- lsr
- regsize 2, NULL
- and #%0000000000111111
- inc
- inc
- bra dcmp_lzc_calc
- dcmpret:
- plb
- plp
- rtl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement